apache-poi

Faking Method parameters using Mockito/PowerMockito

主宰稳场 提交于 2019-12-11 10:56:03
问题 public class FakeExcelSheet implements Sheet { private final Map<Integer, FakeExcelRow> fakeSheet = new HashMap<Integer, FakeExcelRow>(); @Override public Row createRow(int rowNum) { Row row = new FakeExcelRow(rowNum, fakeSheet); fakeSheet.put(rowNum, (FakeExcelRow)row); return row; } @Override public Row getRow(int rowNum) { if (fakeSheet.get(rowNum) != null) { return fakeSheet.get(rowNum); } else { return createRow(rowNum); } } /**Other unimplemented methods of Apache POI class Sheet**/ }

Unable to see Apache POI updated data value in BarChart in pptx without editing

风流意气都作罢 提交于 2019-12-11 10:10:40
问题 I have a pptx template, it has just 1 slide for testing purpose. The slide has a simple bar chart. I am able to edit the bar chart by double clicking it on pptx file and I could change the values in Sheet1 (Data sheet for Barchart), and, I able to see the changes immediately in BarChart. Now, I am trying to do the same using POI API. I am doing the below steps here Read the template file = "MyTemplate.pptx" - https://docs.google.com/file/d/0B-q0lBy0lKLic3dCSUVsZUdGQzA/edit?usp=sharing Have

How to split the row in apache POI header

岁酱吖の 提交于 2019-12-11 09:50:01
问题 I am trying to create table ind Microsoft Word using apache poi. But I am not being able to generate the header attached for the table. Any suggestions, i can create the attached header using apache poi? I am able to created the entire table but the last 2 columns which are appearing (merge and split), i need to do in java. For the merging for the columns i have used the below code: //merging horizontally by setting grid span instead of using CTHMerge static void mergeCellHorizontally

How to speed up excel reading/writing

我与影子孤独终老i 提交于 2019-12-11 09:49:14
问题 I am using Apache POI to read/write to an excel file for my company as an intern here. My program goes through the excel file which is a big square with top rows computer names and left column user names. 240 computers and 342 users. the sheet[computer][user] is 0 in all spaces and the program calls PSLoggedon for each computer and takes the username(s) currently logged on and increments their 0 so after running it after a month, it shows who is logged in the most to each computer. So far it

Read Password protected excel file(.xlsx) using Java

ぐ巨炮叔叔 提交于 2019-12-11 09:46:43
问题 I have tried the below code, import org.apache.poi.poifs.crypt.Decryptor; import org.apache.poi.poifs.crypt.EncryptionInfo; import org.apache.poi.poifs.filesystem.POIFSFileSystem; POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("D://protectedfile.xlsx")); EncryptionInfo info = new EncryptionInfo(fs); Decryptor d = new Decryptor(info); //Error d.verifyPassword(Decryptor.DEFAULT_PASSWORD); It throws an error compilation error : Cannot instantiate the type Decryptor But eventually

Set new cell value by cell name in Apache POI

点点圈 提交于 2019-12-11 09:39:22
问题 I'm new to Java and Apache POI, but I got this task where I have to read from the command line the name of the Excel file and the name and values of the columns that needs to be modified. So in the end the application will run like this: java test -f test.xls -i B2=10;B3=20;B4=30 I have created a map that holds the cell name and their values, but I don't know how to use this map in order to access cells by their name (eg.: B2) and set the new value (eg.: 10). My code so far is bellow: package

create zip files with arabic characters

ε祈祈猫儿з 提交于 2019-12-11 09:36:29
问题 i have the following situation i have to modify an existing files and return a zip containing this modified files , i'm in web application context what i done up to now is : ///////////////// modifying the existing file with poi librairy FileInputStream inpoi = new FileInputStream("file_path"); POIFSFileSystem fs = new POIFSFileSystem(inpoi); HWPFDocument doc = new HWPFDocument(fs); Range r = doc.getRange(); r.replaceText("<nomPrenom>","test"); byte[] b = doc.getDataStream(); ////////////////

org.apache.poi create excel workbook with date cells

随声附和 提交于 2019-12-11 09:08:09
问题 I have date in java in this format: "2014.01.31 14:24:28". I would like to put it into excel using apache poi library with cell format type: "date". How can I achive this? 回答1: Check here: Change the date in your desired format and use that. Workbook wb = new HSSFWorkbook(); //Workbook wb = new XSSFWorkbook(); CreationHelper createHelper = wb.getCreationHelper(); Sheet sheet = wb.createSheet("new sheet"); // Create a row and put some cells in it. Rows are 0 based. Row row = sheet.createRow(0)

Apache POI - Different active cell is selected from the one I select

好久不见. 提交于 2019-12-11 08:55:04
问题 I'm trying to set the active cell of my multiple sheet workbook. However when I programmatically set it it still selects a different cell from the one I set. Example, I set the active cell to be "C1", but in the output the selected cell is "A500". Here is my code to create the sheets: public FullQuoteDTO CreateQuote(FullQuoteDTO dto){ try { QuoteUserModel tempUser = GlobalMethods.ExtractCustomerDetails(dto.getUser().getCustomer()); ClassLoader classLoader = getClass().getClassLoader(); File

Unable to use XSSF with Excel 2007

巧了我就是萌 提交于 2019-12-11 08:17:59
问题 I am having tough time getting to read data from excel 2007. I am using XSSF to read data from a specific cell of excel but keep getting error - Exception in thread "main" java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setSaveAggressiveNamespaces()Lorg/apache/xmlbeans/XmlOptions; at org.apache.poi.POIXMLDocumentPart.(POIXMLDocumentPart.java:46) This is my piece of code: public static void main(String [] args) throws IOException { InputStream ins = new FileInputStream("C:\\Users\