-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BugZilla 67646 - allow append rows to streaming workbooks #600
base: trunk
Are you sure you want to change the base?
Changes from 6 commits
cb9e1bf
335e274
5f1adc0
cf21581
a818af5
ad0b8fc
5c356b4
b192eb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,9 @@ lib/ | |
|
||
# Compiled module-info class-files | ||
/poi*/src/*/java9/*.class | ||
|
||
.DS_Store | ||
|
||
.project | ||
|
||
.classpath |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/main/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ public class SXSSFSheet implements Sheet, OoxmlSheetExtensions { | |
protected SheetDataWriter _writer; | ||
private int _randomAccessWindowSize = SXSSFWorkbook.DEFAULT_WINDOW_SIZE; | ||
protected AutoSizeColumnTracker _autoSizeColumnTracker; | ||
private int outlineLevelRow; | ||
private int lastFlushedRowNumber = -1; | ||
private boolean allFlushed; | ||
private int leftMostColumn = SpreadsheetVersion.EXCEL2007.getLastColumnIndex(); | ||
|
@@ -215,8 +216,13 @@ public void removeRow(Row row) { | |
* @return Row representing the rownumber or null if its not defined on the sheet | ||
*/ | ||
@Override | ||
public SXSSFRow getRow(int rownum) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might break user code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -1 this cannot be changed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. However, this is compatible with the interface There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok - we might be able to change this but it would need to be in a major release - eg POI 6.0.0 |
||
return _rows.get(rownum); | ||
public Row getRow(int rownum) { | ||
Row row = _rows.get(rownum); | ||
// BugZilla 67646: allow reading all the content | ||
if (row == null) { | ||
row = _sh.getRow(rownum); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use spaces not tabs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will change my IDE settings |
||
} | ||
return row; | ||
} | ||
|
||
/** | ||
|
@@ -249,7 +255,8 @@ public int getFirstRowNum() { | |
*/ | ||
@Override | ||
public int getLastRowNum() { | ||
return _rows.isEmpty() ? -1 : _rows.lastKey(); | ||
// BugZilla 67646 allow append | ||
return _rows.isEmpty() ? _sh.getLastRowNum() : _rows.lastKey(); | ||
} | ||
|
||
/** | ||
|
@@ -1264,7 +1271,7 @@ public void setColumnGroupCollapsed(int columnNumber, boolean collapsed) { | |
*/ | ||
@Override | ||
public void groupColumn(int fromColumn, int toColumn) { | ||
_sh.groupColumn(fromColumn, toColumn); | ||
_sh.groupColumn(fromColumn,toColumn); | ||
} | ||
|
||
/** | ||
|
@@ -1317,14 +1324,16 @@ public void ungroupColumn(int fromColumn, int toColumn) { | |
*/ | ||
@Override | ||
public void groupRow(int fromRow, int toRow) { | ||
int maxLevelRow = -1; | ||
for(SXSSFRow row : _rows.subMap(fromRow, toRow + 1).values()){ | ||
final int level = row.getOutlineLevel() + 1; | ||
int level = row.getOutlineLevel() + 1; | ||
row.setOutlineLevel(level); | ||
maxLevelRow = Math.max(maxLevelRow, level); | ||
|
||
if(level > outlineLevelRow) { | ||
outlineLevelRow = level; | ||
} | ||
} | ||
|
||
setWorksheetOutlineLevelRowIfNecessary((short) Math.min(Short.MAX_VALUE, maxLevelRow)); | ||
setWorksheetOutlineLevelRow(); | ||
} | ||
|
||
/** | ||
|
@@ -1344,16 +1353,19 @@ public void groupRow(int fromRow, int toRow) { | |
public void setRowOutlineLevel(int rownum, int level) { | ||
SXSSFRow row = _rows.get(rownum); | ||
row.setOutlineLevel(level); | ||
setWorksheetOutlineLevelRowIfNecessary((short) Math.min(Short.MAX_VALUE, level)); | ||
if(level > 0 && level > outlineLevelRow) { | ||
outlineLevelRow = level; | ||
setWorksheetOutlineLevelRow(); | ||
} | ||
} | ||
|
||
private void setWorksheetOutlineLevelRowIfNecessary(final short levelRow) { | ||
private void setWorksheetOutlineLevelRow() { | ||
CTWorksheet ct = _sh.getCTWorksheet(); | ||
CTSheetFormatPr pr = ct.isSetSheetFormatPr() ? | ||
ct.getSheetFormatPr() : | ||
ct.addNewSheetFormatPr(); | ||
if(levelRow > _sh.getSheetFormatPrOutlineLevelRow()) { | ||
pr.setOutlineLevelRow(levelRow); | ||
if(outlineLevelRow > 0) { | ||
pr.setOutlineLevelRow((short)outlineLevelRow); | ||
} | ||
} | ||
|
||
|
@@ -1375,7 +1387,7 @@ public void ungroupRow(int fromRow, int toRow) { | |
* | ||
* @param row start row of a grouped range of rows (0-based) | ||
* @param collapse whether to expand/collapse the detail rows | ||
* @throws IllegalStateException if collapse is false as this is not implemented for SXSSF. | ||
* @throws RuntimeException if collapse is false as this is not implemented for SXSSF. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, forgot the java doc to fix |
||
*/ | ||
@Override | ||
public void setRowGroupCollapsed(int row, boolean collapse) { | ||
|
@@ -1391,15 +1403,15 @@ public void setRowGroupCollapsed(int row, boolean collapse) { | |
* @param rowIndex the zero based row index to collapse | ||
*/ | ||
private void collapseRow(int rowIndex) { | ||
SXSSFRow row = getRow(rowIndex); | ||
SXSSFRow row = (SXSSFRow) getRow(rowIndex); | ||
if(row == null) { | ||
throw new IllegalArgumentException("Invalid row number("+ rowIndex + "). Row does not exist."); | ||
} else { | ||
int startRow = findStartOfRowOutlineGroup(rowIndex); | ||
|
||
// Hide all the columns until the end of the group | ||
int lastRow = writeHidden(row, startRow); | ||
SXSSFRow lastRowObj = getRow(lastRow); | ||
SXSSFRow lastRowObj = (SXSSFRow) getRow(lastRow); | ||
if (lastRowObj != null) { | ||
lastRowObj.setCollapsed(true); | ||
} else { | ||
|
@@ -1431,12 +1443,12 @@ private int findStartOfRowOutlineGroup(int rowIndex) { | |
|
||
private int writeHidden(SXSSFRow xRow, int rowIndex) { | ||
int level = xRow.getOutlineLevel(); | ||
SXSSFRow currRow = getRow(rowIndex); | ||
SXSSFRow currRow = (SXSSFRow) getRow(rowIndex); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that you've changed getRow to return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, actually the reference to SXSSFRow is not needed here, instead Row would be fine. |
||
|
||
while (currRow != null && currRow.getOutlineLevel() >= level) { | ||
currRow.setHidden(true); | ||
rowIndex++; | ||
currRow = getRow(rowIndex); | ||
currRow = (SXSSFRow) getRow(rowIndex); | ||
} | ||
return rowIndex; | ||
} | ||
|
@@ -2172,6 +2184,11 @@ public void setTabColor(int colorIndex){ | |
pr.setTabColor(color); | ||
} | ||
|
||
/** | ||
* This method is not yet supported. | ||
* | ||
* @throws UnsupportedOperationException this method is not yet supported | ||
*/ | ||
@NotImplemented | ||
@Override | ||
public void shiftColumns(int startColumn, int endColumn, int n){ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/main/ | ||
/test/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all these gitignore changes should be removed - you can update your own user .gitignore but we don't need these in svn - POI is not a Git project - it is an svn project |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't the PR just change code related to the title of the PR? - all other stuff must be reverted