I use POI to generate an excel sheet. When grouping rows using
curSheet.groupRow(firstRow, lastRow)
I noticed that the main Row that stays before collapsing is the last row of the grouping (the row with number lastRow).
How can I change it to first row?
Figured it out.
curSheet.setRowSumsBelow(false)
Related
I have generated an Excel document with jxls and POI. Now POI has merged cell, half data is in page 1 & other half of merged cell in page 2. How can I prevent it?
Unfortunately you can't. That's a disadvantage of Excel. Excel does not provide a "keep merged cells on one page" feature. One need to set an explicit page break above of the row which shall the first on the new page.
Apache POI provides Sheet.setRowBreak to do so.
So you need to know what row is the first one having the merged cells split into two pages. Then set row break to the row above.
For example if first row index of the rows having the merged cells split into two pages is 25, then:
...
Sheet sheet ...
...
sheet.setRowBreak(24);
...
Of course this only can be used if the row positions on the page are static or if one knows how many rows fit to one page. I don't know any more dynamic solution.
Same is if merged columns split over two pages. Then manually set a column break is needed.
Apache POI provides Sheet.setColumnBreak to do so.
Of course this has same disadvantages as manually row break has.
I am trying to figure out why the row on excel gets uploaded which is manually erased(NOT Row delete from right click). Here is the scenario:
PS- I have a logic to trace the empty rows. If no of blank == myColumnCount, I skip the row. Somehow the blank count goes at least greater than 0. Hence gets uploaded
I enter the first row data
I enter the second row
I erase the cells manually of the second row
The data remains only on the first row
I save the file and upload it, POI reads the second row as empty row.
I understand the concept of Physical number of rows but confused as to why this scenario returns the row which has no data ?
I have one Excel sheet which contains two sheets. One is a Data sheet and the second is a pivot sheet.
I have an issue while getting the last row number in the Excel sheet which contains the pivot table.
I am using -version 3.12.x poi.
I tried areaRef.getLastCell().getCol();, newSheet.getLastRowNum(); and pivotTable.getDataSheet().getPhysicalNumberOfRows() and other existing methods also.
But I'm not getting the correct value. Its returning the Data sheet last number of record instead of pivot sheet.
Does anybody know how to get last fill row number in pivot table sheet?
I got my solution. Instead of going through last row number i used footer object.
I am reading a .xslx file using Apache POI in Java.The last row in it is having some borders missing around some cells.
when I am reading this then in the last row after reading "abc"(written in first cell) ,am directly reading "rule1"(written in third cell) and second column is empty and bottom border is missing for it.
So the value of second cell which is empty cell is lost.So how can I be able to know that whether I have skipped any cell due to this formatting problem?
Use Cell.getColumnIndex() to retrieve the current cell's index. With this information you will be able to exactly get its position, and thus also find out whether there were any groups.
I am creating a table using itext. Now while setting header row, if I set table.setheaderrows(2) then it sets first 2 rows as the header. But in my case I want only row no. 2 (not row number 1) to be reprinted while table is extended on the next page.
Is there any way to achieve this?
If you only work with a single PdfPTable, you can't define the second row as the header row that needs to be repeated. The trick is to use two PdfPTable instances with the same widths for the columns. The first one would be a single row table for the first header row, the second one would start with the header row that needs to be repeated. If you add two tables to a document, one right after the other, they are glued to each other and nobody will notice that it's not a single table.