mirror of https://github.com/apache/poi.git
Solved the internal usage of getRow() by replacing the calls to getSXSSFRow()
This commit is contained in:
parent
5c356b4773
commit
b192eb5caf
|
@ -211,6 +211,8 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
|
||||||
/**
|
/**
|
||||||
* Returns the logical row (not physical) 0-based. If you ask for a row that is not
|
* Returns the logical row (not physical) 0-based. If you ask for a row that is not
|
||||||
* defined you get a null. This is to say row 4 represents the fifth row on a sheet.
|
* defined you get a null. This is to say row 4 represents the fifth row on a sheet.
|
||||||
|
* If the row is not created in this streaming sheet, instead is part of the XSSFSheet
|
||||||
|
* then this method takes the row from the XSSFSheet.
|
||||||
*
|
*
|
||||||
* @param rownum row to get (0-based)
|
* @param rownum row to get (0-based)
|
||||||
* @return Row representing the rownumber or null if its not defined on the sheet
|
* @return Row representing the rownumber or null if its not defined on the sheet
|
||||||
|
@ -218,13 +220,25 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
|
||||||
@Override
|
@Override
|
||||||
public Row getRow(int rownum) {
|
public Row getRow(int rownum) {
|
||||||
Row row = _rows.get(rownum);
|
Row row = _rows.get(rownum);
|
||||||
// BugZilla 67646: allow reading all the content
|
// BugZilla 67646: allow reading all the content also from template sheet
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
row = _sh.getRow(rownum);
|
row = _sh.getRow(rownum);
|
||||||
}
|
}
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the logical row (not physical) 0-based. If you ask for a row that is not
|
||||||
|
* defined you get a null. This is to say row 4 represents the fifth row on a sheet.
|
||||||
|
*
|
||||||
|
* @param rownum row to get (0-based)
|
||||||
|
* @return Row representing the rownumber or null if its not defined on the sheet
|
||||||
|
*/
|
||||||
|
private SXSSFRow getSXSSFRow(int rownum) {
|
||||||
|
SXSSFRow row = _rows.get(rownum);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of physically defined rows (NOT the number of rows in the sheet)
|
* Returns the number of physically defined rows (NOT the number of rows in the sheet)
|
||||||
*
|
*
|
||||||
|
@ -1387,7 +1401,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
|
||||||
*
|
*
|
||||||
* @param row start row of a grouped range of rows (0-based)
|
* @param row start row of a grouped range of rows (0-based)
|
||||||
* @param collapse whether to expand/collapse the detail rows
|
* @param collapse whether to expand/collapse the detail rows
|
||||||
* @throws RuntimeException if collapse is false as this is not implemented for SXSSF.
|
* @throws IllegalStateException if collapse is false as this is not implemented for SXSSF.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setRowGroupCollapsed(int row, boolean collapse) {
|
public void setRowGroupCollapsed(int row, boolean collapse) {
|
||||||
|
@ -1403,7 +1417,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
|
||||||
* @param rowIndex the zero based row index to collapse
|
* @param rowIndex the zero based row index to collapse
|
||||||
*/
|
*/
|
||||||
private void collapseRow(int rowIndex) {
|
private void collapseRow(int rowIndex) {
|
||||||
SXSSFRow row = (SXSSFRow) getRow(rowIndex);
|
SXSSFRow row = getSXSSFRow(rowIndex);
|
||||||
if(row == null) {
|
if(row == null) {
|
||||||
throw new IllegalArgumentException("Invalid row number("+ rowIndex + "). Row does not exist.");
|
throw new IllegalArgumentException("Invalid row number("+ rowIndex + "). Row does not exist.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1411,11 +1425,11 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
|
||||||
|
|
||||||
// Hide all the columns until the end of the group
|
// Hide all the columns until the end of the group
|
||||||
int lastRow = writeHidden(row, startRow);
|
int lastRow = writeHidden(row, startRow);
|
||||||
SXSSFRow lastRowObj = (SXSSFRow) getRow(lastRow);
|
SXSSFRow lastRowObj = getSXSSFRow(lastRow);
|
||||||
if (lastRowObj != null) {
|
if (lastRowObj != null) {
|
||||||
lastRowObj.setCollapsed(true);
|
lastRowObj.setCollapsed(true);
|
||||||
} else {
|
} else {
|
||||||
SXSSFRow newRow = createRow(lastRow);
|
SXSSFRow newRow = createRow(lastRow);
|
||||||
newRow.setCollapsed(true);
|
newRow.setCollapsed(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1441,14 +1455,13 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions {
|
||||||
return currentRow + 1;
|
return currentRow + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int writeHidden(SXSSFRow xRow, int rowIndex) {
|
private int writeHidden(Row xRow, int rowIndex) {
|
||||||
int level = xRow.getOutlineLevel();
|
int level = xRow.getOutlineLevel();
|
||||||
SXSSFRow currRow = (SXSSFRow) getRow(rowIndex);
|
SXSSFRow currRow = getSXSSFRow(rowIndex);
|
||||||
|
|
||||||
while (currRow != null && currRow.getOutlineLevel() >= level) {
|
while (currRow != null && currRow.getOutlineLevel() >= level) {
|
||||||
currRow.setHidden(true);
|
currRow.setHidden(true);
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
currRow = (SXSSFRow) getRow(rowIndex);
|
currRow = getSXSSFRow(rowIndex);
|
||||||
}
|
}
|
||||||
return rowIndex;
|
return rowIndex;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue