-
Notifications
You must be signed in to change notification settings - Fork 773
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 all 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(); | ||
|
@@ -210,13 +211,32 @@ public void removeRow(Row 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. | ||
* 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) | ||
* @return Row representing the rownumber or null if its not defined on the sheet | ||
*/ | ||
@Override | ||
public SXSSFRow getRow(int rownum) { | ||
return _rows.get(rownum); | ||
public Row getRow(int rownum) { | ||
Row row = _rows.get(rownum); | ||
// BugZilla 67646: allow reading all the content also from template sheet | ||
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; | ||
} | ||
|
||
/** | ||
* 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; | ||
} | ||
|
||
/** | ||
|
@@ -249,7 +269,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 +1285,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 +1338,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 +1367,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); | ||
} | ||
} | ||
|
||
|
@@ -1391,19 +1417,19 @@ 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 = getSXSSFRow(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 = getSXSSFRow(lastRow); | ||
if (lastRowObj != null) { | ||
lastRowObj.setCollapsed(true); | ||
} else { | ||
SXSSFRow newRow = createRow(lastRow); | ||
SXSSFRow newRow = createRow(lastRow); | ||
newRow.setCollapsed(true); | ||
} | ||
} | ||
|
@@ -1429,14 +1455,13 @@ private int findStartOfRowOutlineGroup(int rowIndex) { | |
return currentRow + 1; | ||
} | ||
|
||
private int writeHidden(SXSSFRow xRow, int rowIndex) { | ||
private int writeHidden(Row xRow, int rowIndex) { | ||
int level = xRow.getOutlineLevel(); | ||
SXSSFRow currRow = getRow(rowIndex); | ||
|
||
SXSSFRow currRow = getSXSSFRow(rowIndex); | ||
while (currRow != null && currRow.getOutlineLevel() >= level) { | ||
currRow.setHidden(true); | ||
rowIndex++; | ||
currRow = getRow(rowIndex); | ||
currRow = getSXSSFRow(rowIndex); | ||
} | ||
return rowIndex; | ||
} | ||
|
@@ -2172,6 +2197,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.
This might break user code.
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.
-1 this cannot be changed
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.
However, this is compatible with the interface
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.
ok - we might be able to change this but it would need to be in a major release - eg POI 6.0.0