I have a Word document (docx); I want to make changes to that document and save the result as another file, leaving the original in place. I have the following code illustrating my current problem: There are three ways I’ve run this, changing commented lines at the bottom of the class file. As you see, there are three lines that
Tag: apache-poi
How to copy a particular row from xsls file and export it to new xlsx file using Apache poi?
I have a folder with 216 xsls files. My logic is to loop throw the folder and read every file, copy the first row of each file and write that row to a new .xsls file. I want to copy the first row without iterating throw the row and read every cell? for example, if you copy the first line
Java how to test correctly mocked instances of POI Row and Cell when use iterator forEach()
Given this code: I can test it with this: But, if I want to use forEach() instead of for loop in getRowAsString() method, like this: The test doesn’t work because when use stream.forEach() the code is not calling method getCell(index). How should I test the method to be able to use forEach() instead of traditional for loop? Answer Yes, I
Creating nested bullet lists in Word using POI v5
I am working in Java, using the following Maven dependency (and no others): and the following class, gleaned from another SO post: This creates a bullet list, as I want; I hope to indent it, but that’s secondary. The real modification I need to make to it is to add two more levels of lists, so that the result, in
How to set Page Breaks View Mode for .xls using hssfwork book ApachePOI
I am creating an .xls excel file using apache poi. I need to set the Page Breaks View by default. But I did look at a related question on .xlsx file . I didn’t find anything “how to set Page Breaks View Mode” to using HSSF of ApachePOI enter image description here Answer The binary BIFF file system of *.xls
How to write dates in Apache POI which would be filtered properly
I have a block of code which write data to .xlsx file. I need to write some date in “dd.MM.yy HH:MM” format. All is work properly, but when I try to open result file and test filter work, I got issue with that. Filter perceives dates just like strings, instead of dates, and I can’t get filter with year and
Java and org.apache.poi while reading excel line 47 is skipped
Using Java 1.8, org.apache.poi 5.1.0 and org.apache.poi.ooxml 5.1.0. I have an excel file that consist of 54 rows. I read through this file in blocks of 5 lines. If I get to line 47 it skips that line and gives me the first line of the new block while it should give me the first empty line above the now
Formula recalculation in excel template POI JAVA
I have an Excel template file with formulas in some cells, I open it and fill in the values using POI. The problem is that the formulas aren’t automatically recalculated. But if I open this file and click on a cell with a value, it recalculates that cell. I found two ways to solve this issue in the documentation, but
How to use Array Spilling with Apache POI 5.1.0
Using Apache POI to generate excel files, is it possible to prevent Excel from adding the implicit intersection operator (@) inside formulas ? For instance, using the following code, what I want to do is copy all the values inside the columns from A to K, using Excel Array Spilling behaviour. However, when opening the file using Excel Desktop (version
remove specific legend apache poi excel graph XDDFChartLegend
i am using apache poi 5.0.0 version i have generated a graph in excel using the data and i am able to see the legends in the bottom of the graph. There are six legends shown. Now i want to remove two specific legends without removing them from the graph. There seems to be no functions available in XDDFChartLegend which