Add missing @Overrides, reformat some files, increase coverage slightly,
comments, fix Eclipse warnings and add close() calls in some tests and in HMEFMessage() to close files during tests correctly. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1602008 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b9dee7bd46
commit
9d1d93b88f
@ -28,6 +28,7 @@ under the License.
|
|||||||
Rainer Klute klute@rainer-klute.de
|
Rainer Klute klute@rainer-klute.de
|
||||||
Bruno Girin brunogirin@gmail.com
|
Bruno Girin brunogirin@gmail.com
|
||||||
Yegor Kozlov yegor at apache.org
|
Yegor Kozlov yegor at apache.org
|
||||||
|
Dominik Stadler centic at apache.org
|
||||||
|
|
||||||
This build was tested with ant 1.6.2 although it will probably work with
|
This build was tested with ant 1.6.2 although it will probably work with
|
||||||
other versions. The following jar files should be available on the
|
other versions. The following jar files should be available on the
|
||||||
@ -40,7 +41,7 @@ under the License.
|
|||||||
To build the documentation you will need to install forrest and set
|
To build the documentation you will need to install forrest and set
|
||||||
the FORREST_HOME environment variable. Forrest 0.5.1 required.
|
the FORREST_HOME environment variable. Forrest 0.5.1 required.
|
||||||
|
|
||||||
You currently need JDK 1.6 or newer to build POI.
|
Since POI 3.11 you will need JDK 1.6 or newer to build POI.
|
||||||
|
|
||||||
Some people may find the tests hang when run through Ant. If this
|
Some people may find the tests hang when run through Ant. If this
|
||||||
happens to you, try giving Ant some more memory when you run it, eg:
|
happens to you, try giving Ant some more memory when you run it, eg:
|
||||||
|
@ -114,6 +114,7 @@ public class CustomProperty extends MutableProperty
|
|||||||
/**
|
/**
|
||||||
* @see java.util.AbstractSet#hashCode()
|
* @see java.util.AbstractSet#hashCode()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return (int) this.getID();
|
return (int) this.getID();
|
||||||
|
@ -133,6 +133,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @return the sheet this cell belongs to
|
* @return the sheet this cell belongs to
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFSheet getSheet() {
|
public XSSFSheet getSheet() {
|
||||||
return getRow().getSheet();
|
return getRow().getSheet();
|
||||||
}
|
}
|
||||||
@ -142,6 +143,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @return the row this cell belongs to
|
* @return the row this cell belongs to
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFRow getRow() {
|
public XSSFRow getRow() {
|
||||||
return _row;
|
return _row;
|
||||||
}
|
}
|
||||||
@ -155,6 +157,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()}
|
* @throws IllegalStateException if the cell type returned by {@link #getCellType()}
|
||||||
* is not CELL_TYPE_BOOLEAN, CELL_TYPE_BLANK or CELL_TYPE_FORMULA
|
* is not CELL_TYPE_BOOLEAN, CELL_TYPE_BLANK or CELL_TYPE_FORMULA
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getBooleanCellValue() {
|
public boolean getBooleanCellValue() {
|
||||||
int cellType = getCellType();
|
int cellType = getCellType();
|
||||||
switch(cellType) {
|
switch(cellType) {
|
||||||
@ -177,6 +180,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* precalculated value, for booleans we'll set its value. For other types we
|
* precalculated value, for booleans we'll set its value. For other types we
|
||||||
* will change the cell to a boolean cell and set its value.
|
* will change the cell to a boolean cell and set its value.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellValue(boolean value) {
|
public void setCellValue(boolean value) {
|
||||||
_cell.setT(STCellType.B);
|
_cell.setT(STCellType.B);
|
||||||
_cell.setV(value ? TRUE_AS_STRING : FALSE_AS_STRING);
|
_cell.setV(value ? TRUE_AS_STRING : FALSE_AS_STRING);
|
||||||
@ -193,6 +197,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||||
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
|
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public double getNumericCellValue() {
|
public double getNumericCellValue() {
|
||||||
int cellType = getCellType();
|
int cellType = getCellType();
|
||||||
switch(cellType) {
|
switch(cellType) {
|
||||||
@ -222,6 +227,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* precalculated value, for numerics we'll set its value. For other types we
|
* precalculated value, for numerics we'll set its value. For other types we
|
||||||
* will change the cell to a numeric cell and set its value.
|
* will change the cell to a numeric cell and set its value.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellValue(double value) {
|
public void setCellValue(double value) {
|
||||||
if(Double.isInfinite(value)) {
|
if(Double.isInfinite(value)) {
|
||||||
// Excel does not support positive/negative infinities,
|
// Excel does not support positive/negative infinities,
|
||||||
@ -247,6 +253,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* </p>
|
* </p>
|
||||||
* @return the value of the cell as a string
|
* @return the value of the cell as a string
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getStringCellValue() {
|
public String getStringCellValue() {
|
||||||
XSSFRichTextString str = getRichStringCellValue();
|
XSSFRichTextString str = getRichStringCellValue();
|
||||||
return str == null ? null : str.getString();
|
return str == null ? null : str.getString();
|
||||||
@ -260,6 +267,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* </p>
|
* </p>
|
||||||
* @return the value of the cell as a XSSFRichTextString
|
* @return the value of the cell as a XSSFRichTextString
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFRichTextString getRichStringCellValue() {
|
public XSSFRichTextString getRichStringCellValue() {
|
||||||
int cellType = getCellType();
|
int cellType = getCellType();
|
||||||
XSSFRichTextString rt;
|
XSSFRichTextString rt;
|
||||||
@ -316,6 +324,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* change the cell to a string cell and set its value.
|
* change the cell to a string cell and set its value.
|
||||||
* If value is null then we will change the cell to a Blank cell.
|
* If value is null then we will change the cell to a Blank cell.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellValue(String str) {
|
public void setCellValue(String str) {
|
||||||
setCellValue(str == null ? null : new XSSFRichTextString(str));
|
setCellValue(str == null ? null : new XSSFRichTextString(str));
|
||||||
}
|
}
|
||||||
@ -328,6 +337,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* change the cell to a string cell and set its value.
|
* change the cell to a string cell and set its value.
|
||||||
* If value is null then we will change the cell to a Blank cell.
|
* If value is null then we will change the cell to a Blank cell.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellValue(RichTextString str) {
|
public void setCellValue(RichTextString str) {
|
||||||
if(str == null || str.getString() == null){
|
if(str == null || str.getString() == null){
|
||||||
setCellType(Cell.CELL_TYPE_BLANK);
|
setCellType(Cell.CELL_TYPE_BLANK);
|
||||||
@ -360,6 +370,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @return a formula for the cell
|
* @return a formula for the cell
|
||||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not CELL_TYPE_FORMULA
|
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not CELL_TYPE_FORMULA
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getCellFormula() {
|
public String getCellFormula() {
|
||||||
int cellType = getCellType();
|
int cellType = getCellType();
|
||||||
if(cellType != CELL_TYPE_FORMULA) throw typeMismatch(CELL_TYPE_FORMULA, cellType, false);
|
if(cellType != CELL_TYPE_FORMULA) throw typeMismatch(CELL_TYPE_FORMULA, cellType, false);
|
||||||
@ -417,6 +428,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @throws IllegalStateException if the operation is not allowed, for example,
|
* @throws IllegalStateException if the operation is not allowed, for example,
|
||||||
* when the cell is a part of a multi-cell array formula
|
* when the cell is a part of a multi-cell array formula
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellFormula(String formula) {
|
public void setCellFormula(String formula) {
|
||||||
if(isPartOfArrayFormulaGroup()){
|
if(isPartOfArrayFormulaGroup()){
|
||||||
notifyArrayFormulaChanging();
|
notifyArrayFormulaChanging();
|
||||||
@ -454,6 +466,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @return zero-based column index of a column in a sheet.
|
* @return zero-based column index of a column in a sheet.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getColumnIndex() {
|
public int getColumnIndex() {
|
||||||
return this._cellNum;
|
return this._cellNum;
|
||||||
}
|
}
|
||||||
@ -463,6 +476,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @return zero-based row index of a row in the sheet that contains this cell
|
* @return zero-based row index of a row in the sheet that contains this cell
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getRowIndex() {
|
public int getRowIndex() {
|
||||||
return _row.getRowNum();
|
return _row.getRowNum();
|
||||||
}
|
}
|
||||||
@ -485,6 +499,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @return the cell's style.</code>
|
* @return the cell's style.</code>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFCellStyle getCellStyle() {
|
public XSSFCellStyle getCellStyle() {
|
||||||
XSSFCellStyle style = null;
|
XSSFCellStyle style = null;
|
||||||
if(_stylesSource.getNumCellStyles() > 0){
|
if(_stylesSource.getNumCellStyles() > 0){
|
||||||
@ -501,6 +516,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @param style reference contained in the workbook.
|
* @param style reference contained in the workbook.
|
||||||
* If the value is null then the style information is removed causing the cell to used the default workbook style.
|
* If the value is null then the style information is removed causing the cell to used the default workbook style.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellStyle(CellStyle style) {
|
public void setCellStyle(CellStyle style) {
|
||||||
if(style == null) {
|
if(style == null) {
|
||||||
if(_cell.isSetS()) _cell.unsetS();
|
if(_cell.isSetS()) _cell.unsetS();
|
||||||
@ -524,6 +540,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @see Cell#CELL_TYPE_BOOLEAN
|
* @see Cell#CELL_TYPE_BOOLEAN
|
||||||
* @see Cell#CELL_TYPE_ERROR
|
* @see Cell#CELL_TYPE_ERROR
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getCellType() {
|
public int getCellType() {
|
||||||
|
|
||||||
if (_cell.getF() != null || getSheet().isCellInArrayFormulaContext(this)) {
|
if (_cell.getF() != null || getSheet().isCellInArrayFormulaContext(this)) {
|
||||||
@ -539,6 +556,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* {@link #CELL_TYPE_BOOLEAN}, {@link #CELL_TYPE_ERROR}) depending
|
* {@link #CELL_TYPE_BOOLEAN}, {@link #CELL_TYPE_ERROR}) depending
|
||||||
* on the cached value of the formula
|
* on the cached value of the formula
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getCachedFormulaResultType() {
|
public int getCachedFormulaResultType() {
|
||||||
if (_cell.getF() == null) {
|
if (_cell.getF() == null) {
|
||||||
throw new IllegalStateException("Only formula cells have cached results");
|
throw new IllegalStateException("Only formula cells have cached results");
|
||||||
@ -585,6 +603,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
* @exception NumberFormatException if the cell value isn't a parsable <code>double</code>.
|
||||||
* @see DataFormatter for formatting this date into a string similar to how excel does.
|
* @see DataFormatter for formatting this date into a string similar to how excel does.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Date getDateCellValue() {
|
public Date getDateCellValue() {
|
||||||
int cellType = getCellType();
|
int cellType = getCellType();
|
||||||
if (cellType == CELL_TYPE_BLANK) {
|
if (cellType == CELL_TYPE_BLANK) {
|
||||||
@ -604,6 +623,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* precalculated value, for numerics we'll set its value. For other types we
|
* precalculated value, for numerics we'll set its value. For other types we
|
||||||
* will change the cell to a numeric cell and set its value.
|
* will change the cell to a numeric cell and set its value.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellValue(Date value) {
|
public void setCellValue(Date value) {
|
||||||
boolean date1904 = getSheet().getWorkbook().isDate1904();
|
boolean date1904 = getSheet().getWorkbook().isDate1904();
|
||||||
setCellValue(DateUtil.getExcelDate(value, date1904));
|
setCellValue(DateUtil.getExcelDate(value, date1904));
|
||||||
@ -625,6 +645,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* precalculated value, for numerics we'll set its value. For othertypes we
|
* precalculated value, for numerics we'll set its value. For othertypes we
|
||||||
* will change the cell to a numeric cell and set its value.
|
* will change the cell to a numeric cell and set its value.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellValue(Calendar value) {
|
public void setCellValue(Calendar value) {
|
||||||
boolean date1904 = getSheet().getWorkbook().isDate1904();
|
boolean date1904 = getSheet().getWorkbook().isDate1904();
|
||||||
setCellValue( DateUtil.getExcelDate(value, date1904 ));
|
setCellValue( DateUtil.getExcelDate(value, date1904 ));
|
||||||
@ -654,6 +675,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't CELL_TYPE_ERROR
|
* @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't CELL_TYPE_ERROR
|
||||||
* @see FormulaError
|
* @see FormulaError
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public byte getErrorCellValue() {
|
public byte getErrorCellValue() {
|
||||||
String code = getErrorCellString();
|
String code = getErrorCellString();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
@ -672,6 +694,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* cell and set its value.
|
* cell and set its value.
|
||||||
* @see FormulaError
|
* @see FormulaError
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellErrorValue(byte errorCode) {
|
public void setCellErrorValue(byte errorCode) {
|
||||||
FormulaError error = FormulaError.forInt(errorCode);
|
FormulaError error = FormulaError.forInt(errorCode);
|
||||||
setCellErrorValue(error);
|
setCellErrorValue(error);
|
||||||
@ -693,6 +716,7 @@ public final class XSSFCell implements Cell {
|
|||||||
/**
|
/**
|
||||||
* Sets this cell as the active cell for the worksheet.
|
* Sets this cell as the active cell for the worksheet.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setAsActiveCell() {
|
public void setAsActiveCell() {
|
||||||
getSheet().setActiveCell(getReference());
|
getSheet().setActiveCell(getReference());
|
||||||
}
|
}
|
||||||
@ -731,6 +755,7 @@ public final class XSSFCell implements Cell {
|
|||||||
* @see #CELL_TYPE_BOOLEAN
|
* @see #CELL_TYPE_BOOLEAN
|
||||||
* @see #CELL_TYPE_ERROR
|
* @see #CELL_TYPE_ERROR
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellType(int cellType) {
|
public void setCellType(int cellType) {
|
||||||
int prevType = getCellType();
|
int prevType = getCellType();
|
||||||
|
|
||||||
@ -873,6 +898,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @return the cell comment associated with this cell or <code>null</code>
|
* @return the cell comment associated with this cell or <code>null</code>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFComment getCellComment() {
|
public XSSFComment getCellComment() {
|
||||||
return getSheet().getCellComment(_row.getRowNum(), getColumnIndex());
|
return getSheet().getCellComment(_row.getRowNum(), getColumnIndex());
|
||||||
}
|
}
|
||||||
@ -883,6 +909,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @param comment the XSSFComment associated with this cell
|
* @param comment the XSSFComment associated with this cell
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setCellComment(Comment comment) {
|
public void setCellComment(Comment comment) {
|
||||||
if(comment == null) {
|
if(comment == null) {
|
||||||
removeCellComment();
|
removeCellComment();
|
||||||
@ -896,6 +923,7 @@ public final class XSSFCell implements Cell {
|
|||||||
/**
|
/**
|
||||||
* Removes the comment for this cell, if there is one.
|
* Removes the comment for this cell, if there is one.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeCellComment() {
|
public void removeCellComment() {
|
||||||
XSSFComment comment = getCellComment();
|
XSSFComment comment = getCellComment();
|
||||||
if(comment != null){
|
if(comment != null){
|
||||||
@ -911,6 +939,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @return hyperlink associated with this cell or <code>null</code> if not found
|
* @return hyperlink associated with this cell or <code>null</code> if not found
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFHyperlink getHyperlink() {
|
public XSSFHyperlink getHyperlink() {
|
||||||
return getSheet().getHyperlink(_row.getRowNum(), _cellNum);
|
return getSheet().getHyperlink(_row.getRowNum(), _cellNum);
|
||||||
}
|
}
|
||||||
@ -920,6 +949,7 @@ public final class XSSFCell implements Cell {
|
|||||||
*
|
*
|
||||||
* @param hyperlink the hyperlink to associate with this cell
|
* @param hyperlink the hyperlink to associate with this cell
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setHyperlink(Hyperlink hyperlink) {
|
public void setHyperlink(Hyperlink hyperlink) {
|
||||||
XSSFHyperlink link = (XSSFHyperlink)hyperlink;
|
XSSFHyperlink link = (XSSFHyperlink)hyperlink;
|
||||||
|
|
||||||
@ -1026,6 +1056,7 @@ public final class XSSFCell implements Cell {
|
|||||||
throw new IllegalStateException("Unexpected formula result type (" + cellType + ")");
|
throw new IllegalStateException("Unexpected formula result type (" + cellType + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CellRangeAddress getArrayFormulaRange() {
|
public CellRangeAddress getArrayFormulaRange() {
|
||||||
XSSFCell cell = getSheet().getFirstCellInArrayFormula(this);
|
XSSFCell cell = getSheet().getFirstCellInArrayFormula(this);
|
||||||
if (cell == null) {
|
if (cell == null) {
|
||||||
@ -1036,6 +1067,7 @@ public final class XSSFCell implements Cell {
|
|||||||
return CellRangeAddress.valueOf(formulaRef);
|
return CellRangeAddress.valueOf(formulaRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isPartOfArrayFormulaGroup() {
|
public boolean isPartOfArrayFormulaGroup() {
|
||||||
return getSheet().isCellInArrayFormulaContext(this);
|
return getSheet().isCellInArrayFormulaContext(this);
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return the parent XSSFWorkbook
|
* @return the parent XSSFWorkbook
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFWorkbook getWorkbook() {
|
public XSSFWorkbook getWorkbook() {
|
||||||
return (XSSFWorkbook)getParent();
|
return (XSSFWorkbook)getParent();
|
||||||
}
|
}
|
||||||
@ -255,6 +256,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return the name of this sheet
|
* @return the name of this sheet
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getSheetName() {
|
public String getSheetName() {
|
||||||
return sheet.getName();
|
return sheet.getName();
|
||||||
}
|
}
|
||||||
@ -265,6 +267,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param region (rowfrom/colfrom-rowto/colto) to merge
|
* @param region (rowfrom/colfrom-rowto/colto) to merge
|
||||||
* @return index of this region
|
* @return index of this region
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int addMergedRegion(CellRangeAddress region) {
|
public int addMergedRegion(CellRangeAddress region) {
|
||||||
region.validate(SpreadsheetVersion.EXCEL2007);
|
region.validate(SpreadsheetVersion.EXCEL2007);
|
||||||
|
|
||||||
@ -315,6 +318,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param column the column index
|
* @param column the column index
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void autoSizeColumn(int column) {
|
public void autoSizeColumn(int column) {
|
||||||
autoSizeColumn(column, false);
|
autoSizeColumn(column, false);
|
||||||
}
|
}
|
||||||
@ -332,6 +336,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param column the column index
|
* @param column the column index
|
||||||
* @param useMergedCells whether to use the contents of merged cells when calculating the width of the column
|
* @param useMergedCells whether to use the contents of merged cells when calculating the width of the column
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void autoSizeColumn(int column, boolean useMergedCells) {
|
public void autoSizeColumn(int column, boolean useMergedCells) {
|
||||||
double width = SheetUtil.getColumnWidth(this, column, useMergedCells);
|
double width = SheetUtil.getColumnWidth(this, column, useMergedCells);
|
||||||
|
|
||||||
@ -351,6 +356,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return a SpreadsheetML drawing
|
* @return a SpreadsheetML drawing
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFDrawing createDrawingPatriarch() {
|
public XSSFDrawing createDrawingPatriarch() {
|
||||||
XSSFDrawing drawing = null;
|
XSSFDrawing drawing = null;
|
||||||
CTDrawing ctDrawing = getCTDrawing();
|
CTDrawing ctDrawing = getCTDrawing();
|
||||||
@ -438,6 +444,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param colSplit Horizonatal position of split.
|
* @param colSplit Horizonatal position of split.
|
||||||
* @param rowSplit Vertical position of split.
|
* @param rowSplit Vertical position of split.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void createFreezePane(int colSplit, int rowSplit) {
|
public void createFreezePane(int colSplit, int rowSplit) {
|
||||||
createFreezePane( colSplit, rowSplit, colSplit, rowSplit );
|
createFreezePane( colSplit, rowSplit, colSplit, rowSplit );
|
||||||
}
|
}
|
||||||
@ -454,6 +461,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param leftmostColumn Left column visible in right pane.
|
* @param leftmostColumn Left column visible in right pane.
|
||||||
* @param topRow Top row visible in bottom pane
|
* @param topRow Top row visible in bottom pane
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow) {
|
public void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow) {
|
||||||
CTSheetView ctView = getDefaultSheetView();
|
CTSheetView ctView = getDefaultSheetView();
|
||||||
|
|
||||||
@ -517,6 +525,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @return High level {@link XSSFRow} object representing a row in the sheet
|
* @return High level {@link XSSFRow} object representing a row in the sheet
|
||||||
* @see #removeRow(org.apache.poi.ss.usermodel.Row)
|
* @see #removeRow(org.apache.poi.ss.usermodel.Row)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFRow createRow(int rownum) {
|
public XSSFRow createRow(int rownum) {
|
||||||
CTRow ctRow;
|
CTRow ctRow;
|
||||||
XSSFRow prev = _rows.get(rownum);
|
XSSFRow prev = _rows.get(rownum);
|
||||||
@ -553,12 +562,14 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @see org.apache.poi.ss.usermodel.Sheet#PANE_UPPER_LEFT
|
* @see org.apache.poi.ss.usermodel.Sheet#PANE_UPPER_LEFT
|
||||||
* @see org.apache.poi.ss.usermodel.Sheet#PANE_UPPER_RIGHT
|
* @see org.apache.poi.ss.usermodel.Sheet#PANE_UPPER_RIGHT
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane) {
|
public void createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane) {
|
||||||
createFreezePane(xSplitPos, ySplitPos, leftmostColumn, topRow);
|
createFreezePane(xSplitPos, ySplitPos, leftmostColumn, topRow);
|
||||||
getPane().setState(STPaneState.SPLIT);
|
getPane().setState(STPaneState.SPLIT);
|
||||||
getPane().setActivePane(STPane.Enum.forInt(activePane));
|
getPane().setActivePane(STPane.Enum.forInt(activePane));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public XSSFComment getCellComment(int row, int column) {
|
public XSSFComment getCellComment(int row, int column) {
|
||||||
if (sheetComments == null) {
|
if (sheetComments == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -589,6 +600,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return column indexes of all the vertical page breaks, never <code>null</code>
|
* @return column indexes of all the vertical page breaks, never <code>null</code>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public int[] getColumnBreaks() {
|
public int[] getColumnBreaks() {
|
||||||
if (!worksheet.isSetColBreaks() || worksheet.getColBreaks().sizeOfBrkArray() == 0) {
|
if (!worksheet.isSetColBreaks() || worksheet.getColBreaks().sizeOfBrkArray() == 0) {
|
||||||
@ -618,6 +630,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param columnIndex - the column to set (0-based)
|
* @param columnIndex - the column to set (0-based)
|
||||||
* @return width - the width in units of 1/256th of a character width
|
* @return width - the width in units of 1/256th of a character width
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getColumnWidth(int columnIndex) {
|
public int getColumnWidth(int columnIndex) {
|
||||||
CTCol col = columnHelper.getColumn(columnIndex, false);
|
CTCol col = columnHelper.getColumn(columnIndex, false);
|
||||||
double width = col == null || !col.isSetWidth() ? getDefaultColumnWidth() : col.getWidth();
|
double width = col == null || !col.isSetWidth() ? getDefaultColumnWidth() : col.getWidth();
|
||||||
@ -633,6 +646,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* </p>
|
* </p>
|
||||||
* @return column width, default value is 8
|
* @return column width, default value is 8
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getDefaultColumnWidth() {
|
public int getDefaultColumnWidth() {
|
||||||
CTSheetFormatPr pr = worksheet.getSheetFormatPr();
|
CTSheetFormatPr pr = worksheet.getSheetFormatPr();
|
||||||
return pr == null ? 8 : (int)pr.getBaseColWidth();
|
return pr == null ? 8 : (int)pr.getBaseColWidth();
|
||||||
@ -644,6 +658,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return default row height
|
* @return default row height
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public short getDefaultRowHeight() {
|
public short getDefaultRowHeight() {
|
||||||
return (short)(getDefaultRowHeightInPoints() * 20);
|
return (short)(getDefaultRowHeightInPoints() * 20);
|
||||||
}
|
}
|
||||||
@ -653,6 +668,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return default row height in points
|
* @return default row height in points
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public float getDefaultRowHeightInPoints() {
|
public float getDefaultRowHeightInPoints() {
|
||||||
CTSheetFormatPr pr = worksheet.getSheetFormatPr();
|
CTSheetFormatPr pr = worksheet.getSheetFormatPr();
|
||||||
return (float)(pr == null ? 0 : pr.getDefaultRowHeight());
|
return (float)(pr == null ? 0 : pr.getDefaultRowHeight());
|
||||||
@ -669,6 +685,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* (0 based) column, or null if no style has been
|
* (0 based) column, or null if no style has been
|
||||||
* set for that column
|
* set for that column
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public CellStyle getColumnStyle(int column) {
|
public CellStyle getColumnStyle(int column) {
|
||||||
int idx = columnHelper.getColDefaultStyle(column);
|
int idx = columnHelper.getColDefaultStyle(column);
|
||||||
return getWorkbook().getCellStyleAt((short)(idx == -1 ? 0 : idx));
|
return getWorkbook().getCellStyleAt((short)(idx == -1 ? 0 : idx));
|
||||||
@ -679,6 +696,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param value true for right to left, false otherwise.
|
* @param value true for right to left, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setRightToLeft(boolean value)
|
public void setRightToLeft(boolean value)
|
||||||
{
|
{
|
||||||
CTSheetView view = getDefaultSheetView();
|
CTSheetView view = getDefaultSheetView();
|
||||||
@ -690,6 +708,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return whether the text is displayed in right-to-left mode in the window
|
* @return whether the text is displayed in right-to-left mode in the window
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isRightToLeft()
|
public boolean isRightToLeft()
|
||||||
{
|
{
|
||||||
CTSheetView view = getDefaultSheetView();
|
CTSheetView view = getDefaultSheetView();
|
||||||
@ -702,6 +721,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return boolean - guts or no guts
|
* @return boolean - guts or no guts
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getDisplayGuts() {
|
public boolean getDisplayGuts() {
|
||||||
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
||||||
CTOutlinePr outlinePr = sheetPr.getOutlinePr() == null ? CTOutlinePr.Factory.newInstance() : sheetPr.getOutlinePr();
|
CTOutlinePr outlinePr = sheetPr.getOutlinePr() == null ? CTOutlinePr.Factory.newInstance() : sheetPr.getOutlinePr();
|
||||||
@ -713,6 +733,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param value - guts or no guts
|
* @param value - guts or no guts
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDisplayGuts(boolean value) {
|
public void setDisplayGuts(boolean value) {
|
||||||
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
||||||
CTOutlinePr outlinePr = sheetPr.getOutlinePr() == null ? sheetPr.addNewOutlinePr() : sheetPr.getOutlinePr();
|
CTOutlinePr outlinePr = sheetPr.getOutlinePr() == null ? sheetPr.addNewOutlinePr() : sheetPr.getOutlinePr();
|
||||||
@ -725,6 +746,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return whether all zero values on the worksheet are displayed
|
* @return whether all zero values on the worksheet are displayed
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isDisplayZeros(){
|
public boolean isDisplayZeros(){
|
||||||
CTSheetView view = getDefaultSheetView();
|
CTSheetView view = getDefaultSheetView();
|
||||||
return view == null ? true : view.getShowZeros();
|
return view == null ? true : view.getShowZeros();
|
||||||
@ -736,6 +758,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param value whether to display or hide all zero values on the worksheet
|
* @param value whether to display or hide all zero values on the worksheet
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDisplayZeros(boolean value){
|
public void setDisplayZeros(boolean value){
|
||||||
CTSheetView view = getSheetTypeSheetView();
|
CTSheetView view = getSheetTypeSheetView();
|
||||||
view.setShowZeros(value);
|
view.setShowZeros(value);
|
||||||
@ -746,6 +769,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return the number of the first logical row on the sheet, zero based
|
* @return the number of the first logical row on the sheet, zero based
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getFirstRowNum() {
|
public int getFirstRowNum() {
|
||||||
return _rows.size() == 0 ? 0 : _rows.firstKey();
|
return _rows.size() == 0 ? 0 : _rows.firstKey();
|
||||||
}
|
}
|
||||||
@ -755,6 +779,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return <code>true</code>
|
* @return <code>true</code>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getFitToPage() {
|
public boolean getFitToPage() {
|
||||||
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
||||||
CTPageSetUpPr psSetup = (sheetPr == null || !sheetPr.isSetPageSetUpPr()) ?
|
CTPageSetUpPr psSetup = (sheetPr == null || !sheetPr.isSetPageSetUpPr()) ?
|
||||||
@ -786,6 +811,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* {@link #getOddFooter()} and
|
* {@link #getOddFooter()} and
|
||||||
* {@link #getEvenFooter()}
|
* {@link #getEvenFooter()}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Footer getFooter() {
|
public Footer getFooter() {
|
||||||
// The default footer is an odd footer
|
// The default footer is an odd footer
|
||||||
return getOddFooter();
|
return getOddFooter();
|
||||||
@ -799,6 +825,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* {@link #getOddHeader()} and
|
* {@link #getOddHeader()} and
|
||||||
* {@link #getEvenHeader()}
|
* {@link #getEvenHeader()}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Header getHeader() {
|
public Header getHeader() {
|
||||||
// The default header is an odd header
|
// The default header is an odd header
|
||||||
return getOddHeader();
|
return getOddHeader();
|
||||||
@ -854,15 +881,18 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
/**
|
/**
|
||||||
* Determine whether printed output for this sheet will be horizontally centered.
|
* Determine whether printed output for this sheet will be horizontally centered.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getHorizontallyCenter() {
|
public boolean getHorizontallyCenter() {
|
||||||
CTPrintOptions opts = worksheet.getPrintOptions();
|
CTPrintOptions opts = worksheet.getPrintOptions();
|
||||||
return opts != null && opts.getHorizontalCentered();
|
return opts != null && opts.getHorizontalCentered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getLastRowNum() {
|
public int getLastRowNum() {
|
||||||
return _rows.size() == 0 ? 0 : _rows.lastKey();
|
return _rows.size() == 0 ? 0 : _rows.lastKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public short getLeftCol() {
|
public short getLeftCol() {
|
||||||
String cellRef = worksheet.getSheetViews().getSheetViewArray(0).getTopLeftCell();
|
String cellRef = worksheet.getSheetViews().getSheetViewArray(0).getTopLeftCell();
|
||||||
if(cellRef == null) {
|
if(cellRef == null) {
|
||||||
@ -884,6 +914,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @see Sheet#HeaderMargin
|
* @see Sheet#HeaderMargin
|
||||||
* @see Sheet#FooterMargin
|
* @see Sheet#FooterMargin
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public double getMargin(short margin) {
|
public double getMargin(short margin) {
|
||||||
if (!worksheet.isSetPageMargins()) return 0;
|
if (!worksheet.isSetPageMargins()) return 0;
|
||||||
|
|
||||||
@ -918,6 +949,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @see Sheet#HeaderMargin
|
* @see Sheet#HeaderMargin
|
||||||
* @see Sheet#FooterMargin
|
* @see Sheet#FooterMargin
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setMargin(short margin, double size) {
|
public void setMargin(short margin, double size) {
|
||||||
CTPageMargins pageMargins = worksheet.isSetPageMargins() ?
|
CTPageMargins pageMargins = worksheet.isSetPageMargins() ?
|
||||||
worksheet.getPageMargins() : worksheet.addNewPageMargins();
|
worksheet.getPageMargins() : worksheet.addNewPageMargins();
|
||||||
@ -949,6 +981,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @return the merged region at the specified index
|
* @return the merged region at the specified index
|
||||||
* @throws IllegalStateException if this worksheet does not contain merged regions
|
* @throws IllegalStateException if this worksheet does not contain merged regions
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public CellRangeAddress getMergedRegion(int index) {
|
public CellRangeAddress getMergedRegion(int index) {
|
||||||
CTMergeCells ctMergeCells = worksheet.getMergeCells();
|
CTMergeCells ctMergeCells = worksheet.getMergeCells();
|
||||||
if(ctMergeCells == null) throw new IllegalStateException("This worksheet does not contain merged regions");
|
if(ctMergeCells == null) throw new IllegalStateException("This worksheet does not contain merged regions");
|
||||||
@ -963,6 +996,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return number of merged regions in this worksheet
|
* @return number of merged regions in this worksheet
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getNumMergedRegions() {
|
public int getNumMergedRegions() {
|
||||||
CTMergeCells ctMergeCells = worksheet.getMergeCells();
|
CTMergeCells ctMergeCells = worksheet.getMergeCells();
|
||||||
return ctMergeCells == null ? 0 : ctMergeCells.sizeOfMergeCellArray();
|
return ctMergeCells == null ? 0 : ctMergeCells.sizeOfMergeCellArray();
|
||||||
@ -977,6 +1011,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return null if no pane configured, or the pane information.
|
* @return null if no pane configured, or the pane information.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public PaneInformation getPaneInformation() {
|
public PaneInformation getPaneInformation() {
|
||||||
CTPane pane = getDefaultSheetView().getPane();
|
CTPane pane = getDefaultSheetView().getPane();
|
||||||
// no pane configured
|
// no pane configured
|
||||||
@ -993,6 +1028,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return the number of phsyically defined rows
|
* @return the number of phsyically defined rows
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getPhysicalNumberOfRows() {
|
public int getPhysicalNumberOfRows() {
|
||||||
return _rows.size();
|
return _rows.size();
|
||||||
}
|
}
|
||||||
@ -1002,6 +1038,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return The user model for the print setup object.
|
* @return The user model for the print setup object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFPrintSetup getPrintSetup() {
|
public XSSFPrintSetup getPrintSetup() {
|
||||||
return new XSSFPrintSetup(worksheet);
|
return new XSSFPrintSetup(worksheet);
|
||||||
}
|
}
|
||||||
@ -1011,6 +1048,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return true => protection enabled; false => protection disabled
|
* @return true => protection enabled; false => protection disabled
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getProtect() {
|
public boolean getProtect() {
|
||||||
return worksheet.isSetSheetProtection() && sheetProtectionEnabled();
|
return worksheet.isSetSheetProtection() && sheetProtectionEnabled();
|
||||||
}
|
}
|
||||||
@ -1022,6 +1060,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param password to set for protection. Pass <code>null</code> to remove protection
|
* @param password to set for protection. Pass <code>null</code> to remove protection
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void protectSheet(String password) {
|
public void protectSheet(String password) {
|
||||||
|
|
||||||
if(password != null) {
|
if(password != null) {
|
||||||
@ -1055,6 +1094,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param rownum row to get
|
* @param rownum row to get
|
||||||
* @return <code>XSSFRow</code> representing the rownumber or <code>null</code> if its not defined on the sheet
|
* @return <code>XSSFRow</code> representing the rownumber or <code>null</code> if its not defined on the sheet
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFRow getRow(int rownum) {
|
public XSSFRow getRow(int rownum) {
|
||||||
return _rows.get(rownum);
|
return _rows.get(rownum);
|
||||||
}
|
}
|
||||||
@ -1065,6 +1105,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return row indexes of all the horizontal page breaks, never <code>null</code>
|
* @return row indexes of all the horizontal page breaks, never <code>null</code>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public int[] getRowBreaks() {
|
public int[] getRowBreaks() {
|
||||||
if (!worksheet.isSetRowBreaks() || worksheet.getRowBreaks().sizeOfBrkArray() == 0) {
|
if (!worksheet.isSetRowBreaks() || worksheet.getRowBreaks().sizeOfBrkArray() == 0) {
|
||||||
@ -1093,6 +1134,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* </p>
|
* </p>
|
||||||
* @return <code>true</code> if row summaries appear below detail in the outline
|
* @return <code>true</code> if row summaries appear below detail in the outline
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getRowSumsBelow() {
|
public boolean getRowSumsBelow() {
|
||||||
CTSheetPr sheetPr = worksheet.getSheetPr();
|
CTSheetPr sheetPr = worksheet.getSheetPr();
|
||||||
CTOutlinePr outlinePr = (sheetPr != null && sheetPr.isSetOutlinePr())
|
CTOutlinePr outlinePr = (sheetPr != null && sheetPr.isSetOutlinePr())
|
||||||
@ -1113,6 +1155,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* </p>
|
* </p>
|
||||||
* @param value <code>true</code> if row summaries appear below detail in the outline
|
* @param value <code>true</code> if row summaries appear below detail in the outline
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setRowSumsBelow(boolean value) {
|
public void setRowSumsBelow(boolean value) {
|
||||||
ensureOutlinePr().setSummaryBelow(value);
|
ensureOutlinePr().setSummaryBelow(value);
|
||||||
}
|
}
|
||||||
@ -1130,6 +1173,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* </p>
|
* </p>
|
||||||
* @return <code>true</code> if col summaries appear right of the detail in the outline
|
* @return <code>true</code> if col summaries appear right of the detail in the outline
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getRowSumsRight() {
|
public boolean getRowSumsRight() {
|
||||||
CTSheetPr sheetPr = worksheet.getSheetPr();
|
CTSheetPr sheetPr = worksheet.getSheetPr();
|
||||||
CTOutlinePr outlinePr = (sheetPr != null && sheetPr.isSetOutlinePr())
|
CTOutlinePr outlinePr = (sheetPr != null && sheetPr.isSetOutlinePr())
|
||||||
@ -1150,6 +1194,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* </p>
|
* </p>
|
||||||
* @param value <code>true</code> if col summaries appear right of the detail in the outline
|
* @param value <code>true</code> if col summaries appear right of the detail in the outline
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setRowSumsRight(boolean value) {
|
public void setRowSumsRight(boolean value) {
|
||||||
ensureOutlinePr().setSummaryRight(value);
|
ensureOutlinePr().setSummaryRight(value);
|
||||||
}
|
}
|
||||||
@ -1168,6 +1213,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return true => protection enabled; false => protection disabled
|
* @return true => protection enabled; false => protection disabled
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getScenarioProtect() {
|
public boolean getScenarioProtect() {
|
||||||
return worksheet.isSetSheetProtection() && worksheet.getSheetProtection().getScenarios();
|
return worksheet.isSetSheetProtection() && worksheet.getSheetProtection().getScenarios();
|
||||||
}
|
}
|
||||||
@ -1178,6 +1224,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return integer indicating the rownum (0 based) of the top row
|
* @return integer indicating the rownum (0 based) of the top row
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public short getTopRow() {
|
public short getTopRow() {
|
||||||
String cellRef = getSheetTypeSheetView().getTopLeftCell();
|
String cellRef = getSheetTypeSheetView().getTopLeftCell();
|
||||||
if(cellRef == null) {
|
if(cellRef == null) {
|
||||||
@ -1192,6 +1239,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return whether printed output for this sheet will be vertically centered.
|
* @return whether printed output for this sheet will be vertically centered.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getVerticallyCenter() {
|
public boolean getVerticallyCenter() {
|
||||||
CTPrintOptions opts = worksheet.getPrintOptions();
|
CTPrintOptions opts = worksheet.getPrintOptions();
|
||||||
return opts != null && opts.getVerticalCentered();
|
return opts != null && opts.getVerticalCentered();
|
||||||
@ -1200,6 +1248,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
/**
|
/**
|
||||||
* Group between (0 based) columns
|
* Group between (0 based) columns
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void groupColumn(int fromColumn, int toColumn) {
|
public void groupColumn(int fromColumn, int toColumn) {
|
||||||
groupColumn1Based(fromColumn+1, toColumn+1);
|
groupColumn1Based(fromColumn+1, toColumn+1);
|
||||||
}
|
}
|
||||||
@ -1253,6 +1302,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param fromRow start row (0-based)
|
* @param fromRow start row (0-based)
|
||||||
* @param toRow end row (0-based)
|
* @param toRow end row (0-based)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void groupRow(int fromRow, int toRow) {
|
public void groupRow(int fromRow, int toRow) {
|
||||||
for (int i = fromRow; i <= toRow; i++) {
|
for (int i = fromRow; i <= toRow; i++) {
|
||||||
XSSFRow xrow = getRow(i);
|
XSSFRow xrow = getRow(i);
|
||||||
@ -1287,10 +1337,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
/**
|
/**
|
||||||
* Determines if there is a page break at the indicated column
|
* Determines if there is a page break at the indicated column
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isColumnBroken(int column) {
|
public boolean isColumnBroken(int column) {
|
||||||
int[] colBreaks = getColumnBreaks();
|
int[] colBreaks = getColumnBreaks();
|
||||||
for (int i = 0 ; i < colBreaks.length ; i++) {
|
for (int colBreak : colBreaks) {
|
||||||
if (colBreaks[i] == column) {
|
if (colBreak == column) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1303,6 +1354,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param columnIndex - the column to set (0-based)
|
* @param columnIndex - the column to set (0-based)
|
||||||
* @return hidden - <code>false</code> if the column is visible
|
* @return hidden - <code>false</code> if the column is visible
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isColumnHidden(int columnIndex) {
|
public boolean isColumnHidden(int columnIndex) {
|
||||||
CTCol col = columnHelper.getColumn(columnIndex, false);
|
CTCol col = columnHelper.getColumn(columnIndex, false);
|
||||||
return col != null && col.getHidden();
|
return col != null && col.getHidden();
|
||||||
@ -1313,6 +1365,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return <code>true</code> if this sheet should display formulas.
|
* @return <code>true</code> if this sheet should display formulas.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isDisplayFormulas() {
|
public boolean isDisplayFormulas() {
|
||||||
return getSheetTypeSheetView().getShowFormulas();
|
return getSheetTypeSheetView().getShowFormulas();
|
||||||
}
|
}
|
||||||
@ -1324,6 +1377,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @return <code>true</code> if this sheet displays gridlines.
|
* @return <code>true</code> if this sheet displays gridlines.
|
||||||
* @see #isPrintGridlines() to check if printing of gridlines is turned on or off
|
* @see #isPrintGridlines() to check if printing of gridlines is turned on or off
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isDisplayGridlines() {
|
public boolean isDisplayGridlines() {
|
||||||
return getSheetTypeSheetView().getShowGridLines();
|
return getSheetTypeSheetView().getShowGridLines();
|
||||||
}
|
}
|
||||||
@ -1337,6 +1391,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param show <code>true</code> if this sheet should display gridlines.
|
* @param show <code>true</code> if this sheet should display gridlines.
|
||||||
* @see #setPrintGridlines(boolean)
|
* @see #setPrintGridlines(boolean)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDisplayGridlines(boolean show) {
|
public void setDisplayGridlines(boolean show) {
|
||||||
getSheetTypeSheetView().setShowGridLines(show);
|
getSheetTypeSheetView().setShowGridLines(show);
|
||||||
}
|
}
|
||||||
@ -1352,6 +1407,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return <code>true</code> if this sheet should display row and column headings.
|
* @return <code>true</code> if this sheet should display row and column headings.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isDisplayRowColHeadings() {
|
public boolean isDisplayRowColHeadings() {
|
||||||
return getSheetTypeSheetView().getShowRowColHeaders();
|
return getSheetTypeSheetView().getShowRowColHeaders();
|
||||||
}
|
}
|
||||||
@ -1367,6 +1423,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param show <code>true</code> if this sheet should display row and column headings.
|
* @param show <code>true</code> if this sheet should display row and column headings.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDisplayRowColHeadings(boolean show) {
|
public void setDisplayRowColHeadings(boolean show) {
|
||||||
getSheetTypeSheetView().setShowRowColHeaders(show);
|
getSheetTypeSheetView().setShowRowColHeaders(show);
|
||||||
}
|
}
|
||||||
@ -1376,6 +1433,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return whether gridlines are printed
|
* @return whether gridlines are printed
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isPrintGridlines() {
|
public boolean isPrintGridlines() {
|
||||||
CTPrintOptions opts = worksheet.getPrintOptions();
|
CTPrintOptions opts = worksheet.getPrintOptions();
|
||||||
return opts != null && opts.getGridLines();
|
return opts != null && opts.getGridLines();
|
||||||
@ -1386,6 +1444,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param value boolean to turn on or off the printing of gridlines
|
* @param value boolean to turn on or off the printing of gridlines
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setPrintGridlines(boolean value) {
|
public void setPrintGridlines(boolean value) {
|
||||||
CTPrintOptions opts = worksheet.isSetPrintOptions() ?
|
CTPrintOptions opts = worksheet.isSetPrintOptions() ?
|
||||||
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
|
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
|
||||||
@ -1398,10 +1457,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param row index of the row to test
|
* @param row index of the row to test
|
||||||
* @return <code>true</code> if there is a page break at the indicated row
|
* @return <code>true</code> if there is a page break at the indicated row
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isRowBroken(int row) {
|
public boolean isRowBroken(int row) {
|
||||||
int[] rowBreaks = getRowBreaks();
|
int[] rowBreaks = getRowBreaks();
|
||||||
for (int i = 0 ; i < rowBreaks.length ; i++) {
|
for (int rowBreak : rowBreaks) {
|
||||||
if (rowBreaks[i] == row) {
|
if (rowBreak == row) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1419,6 +1479,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param row the row to break, inclusive
|
* @param row the row to break, inclusive
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setRowBreak(int row) {
|
public void setRowBreak(int row) {
|
||||||
CTPageBreak pgBreak = worksheet.isSetRowBreaks() ? worksheet.getRowBreaks() : worksheet.addNewRowBreaks();
|
CTPageBreak pgBreak = worksheet.isSetRowBreaks() ? worksheet.getRowBreaks() : worksheet.addNewRowBreaks();
|
||||||
if (! isRowBroken(row)) {
|
if (! isRowBroken(row)) {
|
||||||
@ -1435,6 +1496,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
/**
|
/**
|
||||||
* Removes a page break at the indicated column
|
* Removes a page break at the indicated column
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public void removeColumnBreak(int column) {
|
public void removeColumnBreak(int column) {
|
||||||
if (!worksheet.isSetColBreaks()) {
|
if (!worksheet.isSetColBreaks()) {
|
||||||
@ -1456,6 +1518,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param index of the region to unmerge
|
* @param index of the region to unmerge
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeMergedRegion(int index) {
|
public void removeMergedRegion(int index) {
|
||||||
CTMergeCells ctMergeCells = worksheet.getMergeCells();
|
CTMergeCells ctMergeCells = worksheet.getMergeCells();
|
||||||
|
|
||||||
@ -1480,6 +1543,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param row the row to remove.
|
* @param row the row to remove.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeRow(Row row) {
|
public void removeRow(Row row) {
|
||||||
if (row.getSheet() != this) {
|
if (row.getSheet() != this) {
|
||||||
throw new IllegalArgumentException("Specified row does not belong to this sheet");
|
throw new IllegalArgumentException("Specified row does not belong to this sheet");
|
||||||
@ -1498,6 +1562,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
/**
|
/**
|
||||||
* Removes the page break at the indicated row
|
* Removes the page break at the indicated row
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public void removeRowBreak(int row) {
|
public void removeRowBreak(int row) {
|
||||||
if(!worksheet.isSetRowBreaks()) {
|
if(!worksheet.isSetRowBreaks()) {
|
||||||
@ -1532,6 +1597,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)
|
* @see org.apache.poi.ss.usermodel.Workbook#setForceFormulaRecalculation(boolean)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setForceFormulaRecalculation(boolean value) {
|
public void setForceFormulaRecalculation(boolean value) {
|
||||||
CTCalcPr calcPr = getWorkbook().getCTWorkbook().getCalcPr();
|
CTCalcPr calcPr = getWorkbook().getCTWorkbook().getCalcPr();
|
||||||
|
|
||||||
@ -1555,6 +1621,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* Whether Excel will be asked to recalculate all formulas when the
|
* Whether Excel will be asked to recalculate all formulas when the
|
||||||
* workbook is opened.
|
* workbook is opened.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getForceFormulaRecalculation() {
|
public boolean getForceFormulaRecalculation() {
|
||||||
if(worksheet.isSetSheetCalcPr()) {
|
if(worksheet.isSetSheetCalcPr()) {
|
||||||
CTSheetCalcPr calc = worksheet.getSheetCalcPr();
|
CTSheetCalcPr calc = worksheet.getSheetCalcPr();
|
||||||
@ -1568,6 +1635,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* be the third row if say for instance the second row is undefined.
|
* be the third row if say for instance the second row is undefined.
|
||||||
* Call getRowNum() on each row if you care which one it is.
|
* Call getRowNum() on each row if you care which one it is.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Iterator<Row> rowIterator() {
|
public Iterator<Row> rowIterator() {
|
||||||
return (Iterator<Row>)(Iterator<? extends Row>) _rows.values().iterator();
|
return (Iterator<Row>)(Iterator<? extends Row>) _rows.values().iterator();
|
||||||
@ -1577,6 +1645,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* Alias for {@link #rowIterator()} to
|
* Alias for {@link #rowIterator()} to
|
||||||
* allow foreach loops
|
* allow foreach loops
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Iterator<Row> iterator() {
|
public Iterator<Row> iterator() {
|
||||||
return rowIterator();
|
return rowIterator();
|
||||||
}
|
}
|
||||||
@ -1586,6 +1655,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return <code>true</code> if the sheet displays Automatic Page Breaks.
|
* @return <code>true</code> if the sheet displays Automatic Page Breaks.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getAutobreaks() {
|
public boolean getAutobreaks() {
|
||||||
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
||||||
CTPageSetUpPr psSetup = (sheetPr == null || !sheetPr.isSetPageSetUpPr()) ?
|
CTPageSetUpPr psSetup = (sheetPr == null || !sheetPr.isSetPageSetUpPr()) ?
|
||||||
@ -1598,6 +1668,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param value <code>true</code> if the sheet displays Automatic Page Breaks.
|
* @param value <code>true</code> if the sheet displays Automatic Page Breaks.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setAutobreaks(boolean value) {
|
public void setAutobreaks(boolean value) {
|
||||||
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
CTSheetPr sheetPr = getSheetTypeSheetPr();
|
||||||
CTPageSetUpPr psSetup = sheetPr.isSetPageSetUpPr() ? sheetPr.getPageSetUpPr() : sheetPr.addNewPageSetUpPr();
|
CTPageSetUpPr psSetup = sheetPr.isSetPageSetUpPr() ? sheetPr.getPageSetUpPr() : sheetPr.addNewPageSetUpPr();
|
||||||
@ -1615,6 +1686,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param column the column to break, inclusive
|
* @param column the column to break, inclusive
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setColumnBreak(int column) {
|
public void setColumnBreak(int column) {
|
||||||
if (! isColumnBroken(column)) {
|
if (! isColumnBroken(column)) {
|
||||||
CTPageBreak pgBreak = worksheet.isSetColBreaks() ? worksheet.getColBreaks() : worksheet.addNewColBreaks();
|
CTPageBreak pgBreak = worksheet.isSetColBreaks() ? worksheet.getColBreaks() : worksheet.addNewColBreaks();
|
||||||
@ -1628,6 +1700,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setColumnGroupCollapsed(int columnNumber, boolean collapsed) {
|
public void setColumnGroupCollapsed(int columnNumber, boolean collapsed) {
|
||||||
if (collapsed) {
|
if (collapsed) {
|
||||||
collapseColumn(columnNumber);
|
collapseColumn(columnNumber);
|
||||||
@ -1973,6 +2046,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param columnIndex - the column to get (0-based)
|
* @param columnIndex - the column to get (0-based)
|
||||||
* @param hidden - the visiblity state of the column
|
* @param hidden - the visiblity state of the column
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setColumnHidden(int columnIndex, boolean hidden) {
|
public void setColumnHidden(int columnIndex, boolean hidden) {
|
||||||
columnHelper.setColHidden(columnIndex, hidden);
|
columnHelper.setColHidden(columnIndex, hidden);
|
||||||
}
|
}
|
||||||
@ -2021,6 +2095,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param width - the width in units of 1/256th of a character width
|
* @param width - the width in units of 1/256th of a character width
|
||||||
* @throws IllegalArgumentException if width > 255*256 (the maximum column width in Excel is 255 characters)
|
* @throws IllegalArgumentException if width > 255*256 (the maximum column width in Excel is 255 characters)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setColumnWidth(int columnIndex, int width) {
|
public void setColumnWidth(int columnIndex, int width) {
|
||||||
if(width > 255*256) throw new IllegalArgumentException("The maximum column width for an individual cell is 255 characters.");
|
if(width > 255*256) throw new IllegalArgumentException("The maximum column width for an individual cell is 255 characters.");
|
||||||
|
|
||||||
@ -2028,6 +2103,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
columnHelper.setCustomWidth(columnIndex, true);
|
columnHelper.setCustomWidth(columnIndex, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setDefaultColumnStyle(int column, CellStyle style) {
|
public void setDefaultColumnStyle(int column, CellStyle style) {
|
||||||
columnHelper.setColDefaultStyle(column, style);
|
columnHelper.setColDefaultStyle(column, style);
|
||||||
}
|
}
|
||||||
@ -2039,6 +2115,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param width the number of characters. Default value is <code>8</code>.
|
* @param width the number of characters. Default value is <code>8</code>.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDefaultColumnWidth(int width) {
|
public void setDefaultColumnWidth(int width) {
|
||||||
getSheetTypeSheetFormatPr().setBaseColWidth(width);
|
getSheetTypeSheetFormatPr().setBaseColWidth(width);
|
||||||
}
|
}
|
||||||
@ -2049,6 +2126,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param height default row height in twips (1/20 of a point)
|
* @param height default row height in twips (1/20 of a point)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDefaultRowHeight(short height) {
|
public void setDefaultRowHeight(short height) {
|
||||||
setDefaultRowHeightInPoints((float)height / 20);
|
setDefaultRowHeightInPoints((float)height / 20);
|
||||||
}
|
}
|
||||||
@ -2058,6 +2136,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param height default row height measured in point size.
|
* @param height default row height measured in point size.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDefaultRowHeightInPoints(float height) {
|
public void setDefaultRowHeightInPoints(float height) {
|
||||||
CTSheetFormatPr pr = getSheetTypeSheetFormatPr();
|
CTSheetFormatPr pr = getSheetTypeSheetFormatPr();
|
||||||
pr.setDefaultRowHeight(height);
|
pr.setDefaultRowHeight(height);
|
||||||
@ -2069,6 +2148,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param show <code>true</code> if this sheet should display formulas.
|
* @param show <code>true</code> if this sheet should display formulas.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setDisplayFormulas(boolean show) {
|
public void setDisplayFormulas(boolean show) {
|
||||||
getSheetTypeSheetView().setShowFormulas(show);
|
getSheetTypeSheetView().setShowFormulas(show);
|
||||||
}
|
}
|
||||||
@ -2085,6 +2165,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param b <code>true</code> if the Fit to Page print option is enabled.
|
* @param b <code>true</code> if the Fit to Page print option is enabled.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setFitToPage(boolean b) {
|
public void setFitToPage(boolean b) {
|
||||||
getSheetTypePageSetUpPr().setFitToPage(b);
|
getSheetTypePageSetUpPr().setFitToPage(b);
|
||||||
}
|
}
|
||||||
@ -2094,6 +2175,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param value whether to center on page horizontally when printing.
|
* @param value whether to center on page horizontally when printing.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setHorizontallyCenter(boolean value) {
|
public void setHorizontallyCenter(boolean value) {
|
||||||
CTPrintOptions opts = worksheet.isSetPrintOptions() ?
|
CTPrintOptions opts = worksheet.isSetPrintOptions() ?
|
||||||
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
|
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
|
||||||
@ -2105,6 +2187,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param value true to vertically center, false otherwise.
|
* @param value true to vertically center, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setVerticallyCenter(boolean value) {
|
public void setVerticallyCenter(boolean value) {
|
||||||
CTPrintOptions opts = worksheet.isSetPrintOptions() ?
|
CTPrintOptions opts = worksheet.isSetPrintOptions() ?
|
||||||
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
|
worksheet.getPrintOptions() : worksheet.addNewPrintOptions();
|
||||||
@ -2123,6 +2206,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param collapse -
|
* @param collapse -
|
||||||
* boolean value for collapse
|
* boolean value for collapse
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setRowGroupCollapsed(int rowIndex, boolean collapse) {
|
public void setRowGroupCollapsed(int rowIndex, boolean collapse) {
|
||||||
if (collapse) {
|
if (collapse) {
|
||||||
collapseRow(rowIndex);
|
collapseRow(rowIndex);
|
||||||
@ -2302,6 +2386,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param denominator The denominator for the zoom magnification.
|
* @param denominator The denominator for the zoom magnification.
|
||||||
* @see #setZoom(int)
|
* @see #setZoom(int)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setZoom(int numerator, int denominator) {
|
public void setZoom(int numerator, int denominator) {
|
||||||
int zoom = 100*numerator/denominator;
|
int zoom = 100*numerator/denominator;
|
||||||
setZoom(zoom);
|
setZoom(zoom);
|
||||||
@ -2345,6 +2430,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param endRow the row to end shifting
|
* @param endRow the row to end shifting
|
||||||
* @param n the number of rows to shift
|
* @param n the number of rows to shift
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void shiftRows(int startRow, int endRow, int n) {
|
public void shiftRows(int startRow, int endRow, int n) {
|
||||||
shiftRows(startRow, endRow, n, false, false);
|
shiftRows(startRow, endRow, n, false, false);
|
||||||
}
|
}
|
||||||
@ -2364,6 +2450,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param copyRowHeight whether to copy the row height during the shift
|
* @param copyRowHeight whether to copy the row height during the shift
|
||||||
* @param resetOriginalRowHeight whether to set the original row's height to the default
|
* @param resetOriginalRowHeight whether to set the original row's height to the default
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) {
|
public void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight) {
|
||||||
// first remove all rows which will be overwritten
|
// first remove all rows which will be overwritten
|
||||||
@ -2433,6 +2520,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param toprow the top row to show in desktop window pane
|
* @param toprow the top row to show in desktop window pane
|
||||||
* @param leftcol the left column to show in desktop window pane
|
* @param leftcol the left column to show in desktop window pane
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void showInPane(int toprow, int leftcol) {
|
public void showInPane(int toprow, int leftcol) {
|
||||||
CellReference cellReference = new CellReference(toprow, leftcol);
|
CellReference cellReference = new CellReference(toprow, leftcol);
|
||||||
String cellRef = cellReference.formatAsString();
|
String cellRef = cellReference.formatAsString();
|
||||||
@ -2448,11 +2536,13 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows.
|
* @deprecated Use {@link #showInPane(int, int)} as there can be more than 32767 rows.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void showInPane(short toprow, short leftcol) {
|
public void showInPane(short toprow, short leftcol) {
|
||||||
showInPane((int)toprow, (int)leftcol);
|
showInPane((int)toprow, (int)leftcol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void ungroupColumn(int fromColumn, int toColumn) {
|
public void ungroupColumn(int fromColumn, int toColumn) {
|
||||||
CTCols cols = worksheet.getColsArray(0);
|
CTCols cols = worksheet.getColsArray(0);
|
||||||
for (int index = fromColumn; index <= toColumn; index++) {
|
for (int index = fromColumn; index <= toColumn; index++) {
|
||||||
@ -2478,6 +2568,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* @param fromRow start row (0-based)
|
* @param fromRow start row (0-based)
|
||||||
* @param toRow end row (0-based)
|
* @param toRow end row (0-based)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void ungroupRow(int fromRow, int toRow) {
|
public void ungroupRow(int fromRow, int toRow) {
|
||||||
for (int i = fromRow; i <= toRow; i++) {
|
for (int i = fromRow; i <= toRow; i++) {
|
||||||
XSSFRow xrow = getRow(i);
|
XSSFRow xrow = getRow(i);
|
||||||
@ -2522,6 +2613,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @return <code>true</code> if this sheet is selected
|
* @return <code>true</code> if this sheet is selected
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isSelected() {
|
public boolean isSelected() {
|
||||||
CTSheetView view = getDefaultSheetView();
|
CTSheetView view = getDefaultSheetView();
|
||||||
return view != null && view.getTabSelected();
|
return view != null && view.getTabSelected();
|
||||||
@ -2538,6 +2630,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param value <code>true</code> if this sheet is selected
|
* @param value <code>true</code> if this sheet is selected
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public void setSelected(boolean value) {
|
public void setSelected(boolean value) {
|
||||||
CTSheetViews views = getSheetTypeSheetViews();
|
CTSheetViews views = getSheetTypeSheetViews();
|
||||||
@ -3124,6 +3217,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
return SSCellRange.create(firstRow, firstColumn, height, width, temp, XSSFCell.class);
|
return SSCellRange.create(firstRow, firstColumn, height, width, temp, XSSFCell.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CellRange<XSSFCell> setArrayFormula(String formula, CellRangeAddress range) {
|
public CellRange<XSSFCell> setArrayFormula(String formula, CellRangeAddress range) {
|
||||||
|
|
||||||
CellRange<XSSFCell> cr = getCellRange(range);
|
CellRange<XSSFCell> cr = getCellRange(range);
|
||||||
@ -3134,6 +3228,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
return cr;
|
return cr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CellRange<XSSFCell> removeArrayFormula(Cell cell) {
|
public CellRange<XSSFCell> removeArrayFormula(Cell cell) {
|
||||||
if (cell.getSheet() != this) {
|
if (cell.getSheet() != this) {
|
||||||
throw new IllegalArgumentException("Specified cell does not belong to this sheet.");
|
throw new IllegalArgumentException("Specified cell does not belong to this sheet.");
|
||||||
@ -3153,6 +3248,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public DataValidationHelper getDataValidationHelper() {
|
public DataValidationHelper getDataValidationHelper() {
|
||||||
return dataValidationHelper;
|
return dataValidationHelper;
|
||||||
}
|
}
|
||||||
@ -3169,8 +3265,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
List<String> sqref = ctDataValidation.getSqref();
|
List<String> sqref = ctDataValidation.getSqref();
|
||||||
for (String stRef : sqref) {
|
for (String stRef : sqref) {
|
||||||
String[] regions = stRef.split(" ");
|
String[] regions = stRef.split(" ");
|
||||||
for (int i = 0; i < regions.length; i++) {
|
for (String region : regions) {
|
||||||
String[] parts = regions[i].split(":");
|
String[] parts = region.split(":");
|
||||||
CellReference begin = new CellReference(parts[0]);
|
CellReference begin = new CellReference(parts[0]);
|
||||||
CellReference end = parts.length > 1 ? new CellReference(parts[1]) : begin;
|
CellReference end = parts.length > 1 ? new CellReference(parts[1]) : begin;
|
||||||
CellRangeAddress cellRangeAddress = new CellRangeAddress(begin.getRow(), end.getRow(), begin.getCol(), end.getCol());
|
CellRangeAddress cellRangeAddress = new CellRangeAddress(begin.getRow(), end.getRow(), begin.getCol(), end.getCol());
|
||||||
@ -3184,6 +3280,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
return xssfValidations;
|
return xssfValidations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addValidationData(DataValidation dataValidation) {
|
public void addValidationData(DataValidation dataValidation) {
|
||||||
XSSFDataValidation xssfDataValidation = (XSSFDataValidation)dataValidation;
|
XSSFDataValidation xssfDataValidation = (XSSFDataValidation)dataValidation;
|
||||||
CTDataValidations dataValidations = worksheet.getDataValidations();
|
CTDataValidations dataValidations = worksheet.getDataValidations();
|
||||||
@ -3197,6 +3294,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public XSSFAutoFilter setAutoFilter(CellRangeAddress range) {
|
public XSSFAutoFilter setAutoFilter(CellRangeAddress range) {
|
||||||
CTAutoFilter af = worksheet.getAutoFilter();
|
CTAutoFilter af = worksheet.getAutoFilter();
|
||||||
if(af == null) af = worksheet.addNewAutoFilter();
|
if(af == null) af = worksheet.addNewAutoFilter();
|
||||||
@ -3254,6 +3352,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
return tableList;
|
return tableList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public XSSFSheetConditionalFormatting getSheetConditionalFormatting(){
|
public XSSFSheetConditionalFormatting getSheetConditionalFormatting(){
|
||||||
return new XSSFSheetConditionalFormatting(this);
|
return new XSSFSheetConditionalFormatting(this);
|
||||||
}
|
}
|
||||||
@ -3272,21 +3371,25 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public CellRangeAddress getRepeatingRows() {
|
public CellRangeAddress getRepeatingRows() {
|
||||||
return getRepeatingRowsOrColums(true);
|
return getRepeatingRowsOrColums(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public CellRangeAddress getRepeatingColumns() {
|
public CellRangeAddress getRepeatingColumns() {
|
||||||
return getRepeatingRowsOrColums(false);
|
return getRepeatingRowsOrColums(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setRepeatingRows(CellRangeAddress rowRangeRef) {
|
public void setRepeatingRows(CellRangeAddress rowRangeRef) {
|
||||||
CellRangeAddress columnRangeRef = getRepeatingColumns();
|
CellRangeAddress columnRangeRef = getRepeatingColumns();
|
||||||
setRepeatingRowsAndColumns(rowRangeRef, columnRangeRef);
|
setRepeatingRowsAndColumns(rowRangeRef, columnRangeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setRepeatingColumns(CellRangeAddress columnRangeRef) {
|
public void setRepeatingColumns(CellRangeAddress columnRangeRef) {
|
||||||
CellRangeAddress rowRangeRef = getRepeatingRows();
|
CellRangeAddress rowRangeRef = getRepeatingRows();
|
||||||
setRepeatingRowsAndColumns(rowRangeRef, columnRangeRef);
|
setRepeatingRowsAndColumns(rowRangeRef, columnRangeRef);
|
||||||
|
@ -399,6 +399,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @see Workbook#PICTURE_TYPE_DIB
|
* @see Workbook#PICTURE_TYPE_DIB
|
||||||
* @see #getAllPictures()
|
* @see #getAllPictures()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int addPicture(byte[] pictureData, int format) {
|
public int addPicture(byte[] pictureData, int format) {
|
||||||
int imageNumber = getAllPictures().size() + 1;
|
int imageNumber = getAllPictures().size() + 1;
|
||||||
XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true);
|
XSSFPictureData img = (XSSFPictureData)createRelationship(XSSFPictureData.RELATIONS[format], XSSFFactory.getInstance(), imageNumber, true);
|
||||||
@ -446,6 +447,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @throws IllegalArgumentException if the sheet index in invalid
|
* @throws IllegalArgumentException if the sheet index in invalid
|
||||||
* @throws POIXMLException if there were errors when cloning
|
* @throws POIXMLException if there were errors when cloning
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFSheet cloneSheet(int sheetNum) {
|
public XSSFSheet cloneSheet(int sheetNum) {
|
||||||
validateSheetIndex(sheetNum);
|
validateSheetIndex(sheetNum);
|
||||||
|
|
||||||
@ -557,6 +559,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @return the new XSSFCellStyle object
|
* @return the new XSSFCellStyle object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFCellStyle createCellStyle() {
|
public XSSFCellStyle createCellStyle() {
|
||||||
return stylesSource.createCellStyle();
|
return stylesSource.createCellStyle();
|
||||||
}
|
}
|
||||||
@ -567,6 +570,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @return the XSSFDataFormat object
|
* @return the XSSFDataFormat object
|
||||||
* @see org.apache.poi.ss.usermodel.DataFormat
|
* @see org.apache.poi.ss.usermodel.DataFormat
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFDataFormat createDataFormat() {
|
public XSSFDataFormat createDataFormat() {
|
||||||
if (formatter == null)
|
if (formatter == null)
|
||||||
formatter = new XSSFDataFormat(stylesSource);
|
formatter = new XSSFDataFormat(stylesSource);
|
||||||
@ -578,12 +582,14 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @return new font object
|
* @return new font object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFFont createFont() {
|
public XSSFFont createFont() {
|
||||||
XSSFFont font = new XSSFFont();
|
XSSFFont font = new XSSFFont();
|
||||||
font.registerTo(stylesSource);
|
font.registerTo(stylesSource);
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public XSSFName createName() {
|
public XSSFName createName() {
|
||||||
CTDefinedName ctName = CTDefinedName.Factory.newInstance();
|
CTDefinedName ctName = CTDefinedName.Factory.newInstance();
|
||||||
ctName.setName("");
|
ctName.setName("");
|
||||||
@ -598,6 +604,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @return XSSFSheet representing the new sheet.
|
* @return XSSFSheet representing the new sheet.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFSheet createSheet() {
|
public XSSFSheet createSheet() {
|
||||||
String sheetname = "Sheet" + (sheets.size());
|
String sheetname = "Sheet" + (sheets.size());
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
@ -655,6 +662,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* or workbook already contains a sheet with this name
|
* or workbook already contains a sheet with this name
|
||||||
* @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
|
* @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFSheet createSheet(String sheetname) {
|
public XSSFSheet createSheet(String sheetname) {
|
||||||
if (sheetname == null) {
|
if (sheetname == null) {
|
||||||
throw new IllegalArgumentException("sheetName must not be null");
|
throw new IllegalArgumentException("sheetName must not be null");
|
||||||
@ -695,6 +703,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
/**
|
/**
|
||||||
* Finds a font that matches the one with the supplied attributes
|
* Finds a font that matches the one with the supplied attributes
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) {
|
public XSSFFont findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline) {
|
||||||
return stylesSource.findFont(boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
|
return stylesSource.findFont(boldWeight, color, fontHeight, name, italic, strikeout, typeOffset, underline);
|
||||||
}
|
}
|
||||||
@ -704,6 +713,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* which is currently displayed when the workbook is viewed in Excel.
|
* which is currently displayed when the workbook is viewed in Excel.
|
||||||
* 'Selected' sheet(s) is a distinct concept.
|
* 'Selected' sheet(s) is a distinct concept.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getActiveSheetIndex() {
|
public int getActiveSheetIndex() {
|
||||||
//activeTab (Active Sheet Index) Specifies an unsignedInt
|
//activeTab (Active Sheet Index) Specifies an unsignedInt
|
||||||
//that contains the index to the active sheet in this book view.
|
//that contains the index to the active sheet in this book view.
|
||||||
@ -716,6 +726,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @return the list of pictures (a list of {@link XSSFPictureData} objects.)
|
* @return the list of pictures (a list of {@link XSSFPictureData} objects.)
|
||||||
* @see #addPicture(byte[], int)
|
* @see #addPicture(byte[], int)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public List<XSSFPictureData> getAllPictures() {
|
public List<XSSFPictureData> getAllPictures() {
|
||||||
if(pictures == null){
|
if(pictures == null){
|
||||||
List<PackagePart> mediaParts = getPackage().getPartsByName(Pattern.compile("/xl/media/.*?"));
|
List<PackagePart> mediaParts = getPackage().getPartsByName(Pattern.compile("/xl/media/.*?"));
|
||||||
@ -733,6 +744,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param idx index within the set of styles
|
* @param idx index within the set of styles
|
||||||
* @return XSSFCellStyle object at the index
|
* @return XSSFCellStyle object at the index
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFCellStyle getCellStyleAt(short idx) {
|
public XSSFCellStyle getCellStyleAt(short idx) {
|
||||||
return stylesSource.getStyleAt(idx);
|
return stylesSource.getStyleAt(idx);
|
||||||
}
|
}
|
||||||
@ -743,10 +755,12 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param idx index number
|
* @param idx index number
|
||||||
* @return XSSFFont at the index
|
* @return XSSFFont at the index
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFFont getFontAt(short idx) {
|
public XSSFFont getFontAt(short idx) {
|
||||||
return stylesSource.getFontAt(idx);
|
return stylesSource.getFontAt(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public XSSFName getName(String name) {
|
public XSSFName getName(String name) {
|
||||||
int nameIndex = getNameIndex(name);
|
int nameIndex = getNameIndex(name);
|
||||||
if (nameIndex < 0) {
|
if (nameIndex < 0) {
|
||||||
@ -755,6 +769,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
return namedRanges.get(nameIndex);
|
return namedRanges.get(nameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public XSSFName getNameAt(int nameIndex) {
|
public XSSFName getNameAt(int nameIndex) {
|
||||||
int nNames = namedRanges.size();
|
int nNames = namedRanges.size();
|
||||||
if (nNames < 1) {
|
if (nNames < 1) {
|
||||||
@ -775,6 +790,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param name named range name
|
* @param name named range name
|
||||||
* @return named range index
|
* @return named range index
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getNameIndex(String name) {
|
public int getNameIndex(String name) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(XSSFName nr : namedRanges) {
|
for(XSSFName nr : namedRanges) {
|
||||||
@ -791,6 +807,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @return count of cell styles
|
* @return count of cell styles
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public short getNumCellStyles() {
|
public short getNumCellStyles() {
|
||||||
return (short) (stylesSource).getNumCellStyles();
|
return (short) (stylesSource).getNumCellStyles();
|
||||||
}
|
}
|
||||||
@ -800,6 +817,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @return number of fonts
|
* @return number of fonts
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public short getNumberOfFonts() {
|
public short getNumberOfFonts() {
|
||||||
return (short)stylesSource.getFonts().size();
|
return (short)stylesSource.getFonts().size();
|
||||||
}
|
}
|
||||||
@ -809,6 +827,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @return number of named ranges
|
* @return number of named ranges
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getNumberOfNames() {
|
public int getNumberOfNames() {
|
||||||
return namedRanges.size();
|
return namedRanges.size();
|
||||||
}
|
}
|
||||||
@ -818,6 +837,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @return number of worksheets
|
* @return number of worksheets
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getNumberOfSheets() {
|
public int getNumberOfSheets() {
|
||||||
return sheets.size();
|
return sheets.size();
|
||||||
}
|
}
|
||||||
@ -827,6 +847,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
|
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
|
||||||
* @return String Null if no print area has been defined
|
* @return String Null if no print area has been defined
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getPrintArea(int sheetIndex) {
|
public String getPrintArea(int sheetIndex) {
|
||||||
XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
|
XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
|
||||||
if (name == null) return null;
|
if (name == null) return null;
|
||||||
@ -841,6 +862,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param name of the sheet
|
* @param name of the sheet
|
||||||
* @return XSSFSheet with the name provided or <code>null</code> if it does not exist
|
* @return XSSFSheet with the name provided or <code>null</code> if it does not exist
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFSheet getSheet(String name) {
|
public XSSFSheet getSheet(String name) {
|
||||||
for (XSSFSheet sheet : sheets) {
|
for (XSSFSheet sheet : sheets) {
|
||||||
if (name.equalsIgnoreCase(sheet.getSheetName())) {
|
if (name.equalsIgnoreCase(sheet.getSheetName())) {
|
||||||
@ -858,6 +880,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @throws IllegalArgumentException if the index is out of range (index
|
* @throws IllegalArgumentException if the index is out of range (index
|
||||||
* < 0 || index >= getNumberOfSheets()).
|
* < 0 || index >= getNumberOfSheets()).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFSheet getSheetAt(int index) {
|
public XSSFSheet getSheetAt(int index) {
|
||||||
validateSheetIndex(index);
|
validateSheetIndex(index);
|
||||||
return sheets.get(index);
|
return sheets.get(index);
|
||||||
@ -869,6 +892,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param name the sheet name
|
* @param name the sheet name
|
||||||
* @return index of the sheet (0 based) or <tt>-1</tt if not found
|
* @return index of the sheet (0 based) or <tt>-1</tt if not found
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getSheetIndex(String name) {
|
public int getSheetIndex(String name) {
|
||||||
for (int i = 0 ; i < sheets.size() ; ++i) {
|
for (int i = 0 ; i < sheets.size() ; ++i) {
|
||||||
XSSFSheet sheet = sheets.get(i);
|
XSSFSheet sheet = sheets.get(i);
|
||||||
@ -885,6 +909,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param sheet the sheet to look up
|
* @param sheet the sheet to look up
|
||||||
* @return index of the sheet (0 based). <tt>-1</tt> if not found
|
* @return index of the sheet (0 based). <tt>-1</tt> if not found
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getSheetIndex(Sheet sheet) {
|
public int getSheetIndex(Sheet sheet) {
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for(XSSFSheet sh : sheets){
|
for(XSSFSheet sh : sheets){
|
||||||
@ -900,6 +925,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param sheetIx Number
|
* @param sheetIx Number
|
||||||
* @return Sheet name
|
* @return Sheet name
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getSheetName(int sheetIx) {
|
public String getSheetName(int sheetIx) {
|
||||||
validateSheetIndex(sheetIx);
|
validateSheetIndex(sheetIx);
|
||||||
return sheets.get(sheetIx).getSheetName();
|
return sheets.get(sheetIx).getSheetName();
|
||||||
@ -914,6 +940,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* }
|
* }
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Iterator<XSSFSheet> iterator() {
|
public Iterator<XSSFSheet> iterator() {
|
||||||
return sheets.iterator();
|
return sheets.iterator();
|
||||||
}
|
}
|
||||||
@ -925,10 +952,12 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType());
|
return getPackagePart().getContentType().equals(XSSFRelation.MACROS_WORKBOOK.getContentType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void removeName(int nameIndex) {
|
public void removeName(int nameIndex) {
|
||||||
namedRanges.remove(nameIndex);
|
namedRanges.remove(nameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void removeName(String name) {
|
public void removeName(String name) {
|
||||||
for (int i = 0; i < namedRanges.size(); i++) {
|
for (int i = 0; i < namedRanges.size(); i++) {
|
||||||
XSSFName nm = namedRanges.get(i);
|
XSSFName nm = namedRanges.get(i);
|
||||||
@ -959,6 +988,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @param sheetIndex 0-based sheet index (0 = First Sheet)
|
* @param sheetIndex 0-based sheet index (0 = First Sheet)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removePrintArea(int sheetIndex) {
|
public void removePrintArea(int sheetIndex) {
|
||||||
int cont = 0;
|
int cont = 0;
|
||||||
for (XSSFName name : namedRanges) {
|
for (XSSFName name : namedRanges) {
|
||||||
@ -984,6 +1014,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @param index of the sheet (0-based)
|
* @param index of the sheet (0-based)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeSheetAt(int index) {
|
public void removeSheetAt(int index) {
|
||||||
validateSheetIndex(index);
|
validateSheetIndex(index);
|
||||||
|
|
||||||
@ -1029,6 +1060,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* The default is to return blank and null cells.
|
* The default is to return blank and null cells.
|
||||||
* {@link MissingCellPolicy}
|
* {@link MissingCellPolicy}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public MissingCellPolicy getMissingCellPolicy() {
|
public MissingCellPolicy getMissingCellPolicy() {
|
||||||
return _missingCellPolicy;
|
return _missingCellPolicy;
|
||||||
}
|
}
|
||||||
@ -1039,6 +1071,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* {@link Row#getCell(int)}}. See
|
* {@link Row#getCell(int)}}. See
|
||||||
* {@link MissingCellPolicy}
|
* {@link MissingCellPolicy}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
|
public void setMissingCellPolicy(MissingCellPolicy missingCellPolicy) {
|
||||||
_missingCellPolicy = missingCellPolicy;
|
_missingCellPolicy = missingCellPolicy;
|
||||||
}
|
}
|
||||||
@ -1048,6 +1081,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* which is currently displayed when the workbook is viewed in Excel.
|
* which is currently displayed when the workbook is viewed in Excel.
|
||||||
* 'Selected' sheet(s) is a distinct concept.
|
* 'Selected' sheet(s) is a distinct concept.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||||
public void setActiveSheet(int index) {
|
public void setActiveSheet(int index) {
|
||||||
|
|
||||||
@ -1082,6 +1116,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @return integer that contains the index to the active sheet in this book view.
|
* @return integer that contains the index to the active sheet in this book view.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getFirstVisibleTab() {
|
public int getFirstVisibleTab() {
|
||||||
CTBookViews bookViews = workbook.getBookViews();
|
CTBookViews bookViews = workbook.getBookViews();
|
||||||
CTBookView bookView = bookViews.getWorkbookViewArray(0);
|
CTBookView bookView = bookViews.getWorkbookViewArray(0);
|
||||||
@ -1093,6 +1128,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @param index integer that contains the index to the active sheet in this book view.
|
* @param index integer that contains the index to the active sheet in this book view.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setFirstVisibleTab(int index) {
|
public void setFirstVisibleTab(int index) {
|
||||||
CTBookViews bookViews = workbook.getBookViews();
|
CTBookViews bookViews = workbook.getBookViews();
|
||||||
CTBookView bookView= bookViews.getWorkbookViewArray(0);
|
CTBookView bookView= bookViews.getWorkbookViewArray(0);
|
||||||
@ -1106,6 +1142,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
|
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
|
||||||
* @param reference Valid name Reference for the Print Area
|
* @param reference Valid name Reference for the Print Area
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setPrintArea(int sheetIndex, String reference) {
|
public void setPrintArea(int sheetIndex, String reference) {
|
||||||
XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
|
XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
@ -1135,6 +1172,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param startRow Row to begin the printarea
|
* @param startRow Row to begin the printarea
|
||||||
* @param endRow Row to end the printarea
|
* @param endRow Row to end the printarea
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow) {
|
public void setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow) {
|
||||||
String reference=getReferencePrintArea(getSheetName(sheetIndex), startColumn, endColumn, startRow, endRow);
|
String reference=getReferencePrintArea(getSheetName(sheetIndex), startColumn, endColumn, startRow, endRow);
|
||||||
setPrintArea(sheetIndex, reference);
|
setPrintArea(sheetIndex, reference);
|
||||||
@ -1166,6 +1204,8 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @deprecated use {@link XSSFSheet#setRepeatingRows(CellRangeAddress)}
|
* @deprecated use {@link XSSFSheet#setRepeatingRows(CellRangeAddress)}
|
||||||
* or {@link XSSFSheet#setRepeatingColumns(CellRangeAddress)}
|
* or {@link XSSFSheet#setRepeatingColumns(CellRangeAddress)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
public void setRepeatingRowsAndColumns(int sheetIndex,
|
public void setRepeatingRowsAndColumns(int sheetIndex,
|
||||||
int startColumn, int endColumn,
|
int startColumn, int endColumn,
|
||||||
int startRow, int endRow) {
|
int startRow, int endRow) {
|
||||||
@ -1231,6 +1271,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
/**
|
/**
|
||||||
* We only set one sheet as selected for compatibility with HSSF.
|
* We only set one sheet as selected for compatibility with HSSF.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setSelectedTab(int index) {
|
public void setSelectedTab(int index) {
|
||||||
for (int i = 0 ; i < sheets.size() ; ++i) {
|
for (int i = 0 ; i < sheets.size() ; ++i) {
|
||||||
XSSFSheet sheet = sheets.get(i);
|
XSSFSheet sheet = sheets.get(i);
|
||||||
@ -1248,6 +1289,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @see #createSheet(String)
|
* @see #createSheet(String)
|
||||||
* @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
|
* @see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setSheetName(int sheetIndex, String sheetname) {
|
public void setSheetName(int sheetIndex, String sheetname) {
|
||||||
validateSheetIndex(sheetIndex);
|
validateSheetIndex(sheetIndex);
|
||||||
|
|
||||||
@ -1272,6 +1314,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param sheetname the name of the sheet to reorder
|
* @param sheetname the name of the sheet to reorder
|
||||||
* @param pos the position that we want to insert the sheet into (0 based)
|
* @param pos the position that we want to insert the sheet into (0 based)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setSheetOrder(String sheetname, int pos) {
|
public void setSheetOrder(String sheetname, int pos) {
|
||||||
int idx = getSheetIndex(sheetname);
|
int idx = getSheetIndex(sheetname);
|
||||||
sheets.add(pos, sheets.remove(idx));
|
sheets.add(pos, sheets.remove(idx));
|
||||||
@ -1391,6 +1434,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* Returns an object that handles instantiating concrete
|
* Returns an object that handles instantiating concrete
|
||||||
* classes of the various instances for XSSF.
|
* classes of the various instances for XSSF.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public XSSFCreationHelper getCreationHelper() {
|
public XSSFCreationHelper getCreationHelper() {
|
||||||
if(_creationHelper == null) _creationHelper = new XSSFCreationHelper(this);
|
if(_creationHelper == null) _creationHelper = new XSSFCreationHelper(this);
|
||||||
return _creationHelper;
|
return _creationHelper;
|
||||||
@ -1457,10 +1501,12 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
return embedds;
|
return embedds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isHidden() {
|
public boolean isHidden() {
|
||||||
throw new RuntimeException("Not implemented yet");
|
throw new RuntimeException("Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setHidden(boolean hiddenFlag) {
|
public void setHidden(boolean hiddenFlag) {
|
||||||
throw new RuntimeException("Not implemented yet");
|
throw new RuntimeException("Not implemented yet");
|
||||||
}
|
}
|
||||||
@ -1474,6 +1520,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param sheetIx Number
|
* @param sheetIx Number
|
||||||
* @return <code>true</code> if sheet is hidden
|
* @return <code>true</code> if sheet is hidden
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isSheetHidden(int sheetIx) {
|
public boolean isSheetHidden(int sheetIx) {
|
||||||
validateSheetIndex(sheetIx);
|
validateSheetIndex(sheetIx);
|
||||||
CTSheet ctSheet = sheets.get(sheetIx).sheet;
|
CTSheet ctSheet = sheets.get(sheetIx).sheet;
|
||||||
@ -1489,6 +1536,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param sheetIx sheet index to check
|
* @param sheetIx sheet index to check
|
||||||
* @return <code>true</code> if sheet is very hidden
|
* @return <code>true</code> if sheet is very hidden
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isSheetVeryHidden(int sheetIx) {
|
public boolean isSheetVeryHidden(int sheetIx) {
|
||||||
validateSheetIndex(sheetIx);
|
validateSheetIndex(sheetIx);
|
||||||
CTSheet ctSheet = sheets.get(sheetIx).sheet;
|
CTSheet ctSheet = sheets.get(sheetIx).sheet;
|
||||||
@ -1509,6 +1557,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* @param hidden whether this sheet is hidden
|
* @param hidden whether this sheet is hidden
|
||||||
* @see #setSheetHidden(int, int)
|
* @see #setSheetHidden(int, int)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setSheetHidden(int sheetIx, boolean hidden) {
|
public void setSheetHidden(int sheetIx, boolean hidden) {
|
||||||
setSheetHidden(sheetIx, hidden ? SHEET_STATE_HIDDEN : SHEET_STATE_VISIBLE);
|
setSheetHidden(sheetIx, hidden ? SHEET_STATE_HIDDEN : SHEET_STATE_VISIBLE);
|
||||||
}
|
}
|
||||||
@ -1528,6 +1577,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* <code>Workbook.SHEET_STATE_VERY_HIDDEN</code>.
|
* <code>Workbook.SHEET_STATE_VERY_HIDDEN</code>.
|
||||||
* @throws IllegalArgumentException if the supplied sheet index or state is invalid
|
* @throws IllegalArgumentException if the supplied sheet index or state is invalid
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setSheetHidden(int sheetIx, int state) {
|
public void setSheetHidden(int sheetIx, int state) {
|
||||||
validateSheetIndex(sheetIx);
|
validateSheetIndex(sheetIx);
|
||||||
WorkbookUtil.validateSheetState(state);
|
WorkbookUtil.validateSheetState(state);
|
||||||
@ -1691,6 +1741,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @param toopack the toolpack to register
|
* @param toopack the toolpack to register
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void addToolPack(UDFFinder toopack){
|
public void addToolPack(UDFFinder toopack){
|
||||||
_udfFinder.add(toopack);
|
_udfFinder.add(toopack);
|
||||||
}
|
}
|
||||||
@ -1712,6 +1763,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
* workbook values when the workbook is opened
|
* workbook values when the workbook is opened
|
||||||
* @since 3.8
|
* @since 3.8
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setForceFormulaRecalculation(boolean value){
|
public void setForceFormulaRecalculation(boolean value){
|
||||||
CTWorkbook ctWorkbook = getCTWorkbook();
|
CTWorkbook ctWorkbook = getCTWorkbook();
|
||||||
CTCalcPr calcPr = ctWorkbook.isSetCalcPr() ? ctWorkbook.getCalcPr() : ctWorkbook.addNewCalcPr();
|
CTCalcPr calcPr = ctWorkbook.isSetCalcPr() ? ctWorkbook.getCalcPr() : ctWorkbook.addNewCalcPr();
|
||||||
@ -1729,6 +1781,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
|||||||
*
|
*
|
||||||
* @since 3.8
|
* @since 3.8
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean getForceFormulaRecalculation(){
|
public boolean getForceFormulaRecalculation(){
|
||||||
CTWorkbook ctWorkbook = getCTWorkbook();
|
CTWorkbook ctWorkbook = getCTWorkbook();
|
||||||
CTCalcPr calcPr = ctWorkbook.getCalcPr();
|
CTCalcPr calcPr = ctWorkbook.getCalcPr();
|
||||||
|
@ -66,6 +66,8 @@ public class TestXWPFBugs {
|
|||||||
assertNotNull(text);
|
assertNotNull(text);
|
||||||
assertEquals("This is password protected Word document.", text.trim());
|
assertEquals("This is password protected Word document.", text.trim());
|
||||||
ex.close();
|
ex.close();
|
||||||
|
|
||||||
|
filesystem.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,5 +103,7 @@ public class TestXWPFBugs {
|
|||||||
// I know ... a stupid typo, maybe next time ...
|
// I know ... a stupid typo, maybe next time ...
|
||||||
assertEquals("The is a password protected document.", text.trim());
|
assertEquals("The is a password protected document.", text.trim());
|
||||||
ex.close();
|
ex.close();
|
||||||
|
|
||||||
|
filesystem.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ public final class HMEFMessage {
|
|||||||
private List<Attachment> attachments = new ArrayList<Attachment>();
|
private List<Attachment> attachments = new ArrayList<Attachment>();
|
||||||
|
|
||||||
public HMEFMessage(InputStream inp) throws IOException {
|
public HMEFMessage(InputStream inp) throws IOException {
|
||||||
|
try {
|
||||||
// Check the signature matches
|
// Check the signature matches
|
||||||
int sig = LittleEndian.readInt(inp);
|
int sig = LittleEndian.readInt(inp);
|
||||||
if(sig != HEADER_SIGNATURE) {
|
if(sig != HEADER_SIGNATURE) {
|
||||||
@ -61,6 +62,9 @@ public final class HMEFMessage {
|
|||||||
|
|
||||||
// Now begin processing the contents
|
// Now begin processing the contents
|
||||||
process(inp);
|
process(inp);
|
||||||
|
} finally {
|
||||||
|
inp.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void process(InputStream inp) throws IOException {
|
private void process(InputStream inp) throws IOException {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.apache.poi.hmef;
|
package org.apache.poi.hmef;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@ -34,13 +35,16 @@ public abstract class HMEFTest extends TestCase {
|
|||||||
}
|
}
|
||||||
protected void assertContents(String filename, byte[] actual)
|
protected void assertContents(String filename, byte[] actual)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
byte[] expected = IOUtils.toByteArray(
|
InputStream stream = _samples.openResourceAsStream("quick-contents/" + filename);
|
||||||
_samples.openResourceAsStream("quick-contents/" + filename)
|
try {
|
||||||
);
|
byte[] expected = IOUtils.toByteArray(stream);
|
||||||
|
|
||||||
assertEquals(expected.length, actual.length);
|
assertEquals(expected.length, actual.length);
|
||||||
for(int i=0; i<expected.length; i++) {
|
for(int i=0; i<expected.length; i++) {
|
||||||
assertEquals("Byte " + i + " wrong", expected[i], actual[i]);
|
assertEquals("Byte " + i + " wrong", expected[i], actual[i]);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.apache.poi.hmef;
|
package org.apache.poi.hmef;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@ -157,9 +158,9 @@ public final class TestCompressedRTF extends TestCase {
|
|||||||
assertNotNull(attr);
|
assertNotNull(attr);
|
||||||
MAPIRtfAttribute rtfAttr = (MAPIRtfAttribute)attr;
|
MAPIRtfAttribute rtfAttr = (MAPIRtfAttribute)attr;
|
||||||
|
|
||||||
byte[] expected = IOUtils.toByteArray(
|
InputStream stream = _samples.openResourceAsStream("quick-contents/message.rtf");
|
||||||
_samples.openResourceAsStream("quick-contents/message.rtf")
|
try {
|
||||||
);
|
byte[] expected = IOUtils.toByteArray(stream);
|
||||||
|
|
||||||
CompressedRTF comp = new CompressedRTF();
|
CompressedRTF comp = new CompressedRTF();
|
||||||
byte[] data = rtfAttr.getRawData();
|
byte[] data = rtfAttr.getRawData();
|
||||||
@ -186,5 +187,8 @@ public final class TestCompressedRTF extends TestCase {
|
|||||||
String decompStr = rtfAttr.getDataString();
|
String decompStr = rtfAttr.getDataString();
|
||||||
assertEquals(expString.length(), decompStr.length());
|
assertEquals(expString.length(), decompStr.length());
|
||||||
assertEquals(expString, decompStr);
|
assertEquals(expString, decompStr);
|
||||||
|
} finally {
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.apache.poi.hmef.attribute;
|
package org.apache.poi.hmef.attribute;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
@ -32,16 +33,24 @@ import org.apache.poi.util.LittleEndian;
|
|||||||
public final class TestMAPIAttributes extends TestCase {
|
public final class TestMAPIAttributes extends TestCase {
|
||||||
private static final POIDataSamples _samples = POIDataSamples.getHMEFInstance();
|
private static final POIDataSamples _samples = POIDataSamples.getHMEFInstance();
|
||||||
private HMEFMessage quick;
|
private HMEFMessage quick;
|
||||||
|
private InputStream stream;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
quick = new HMEFMessage(
|
stream = _samples.openResourceAsStream("quick-winmail.dat");
|
||||||
_samples.openResourceAsStream("quick-winmail.dat")
|
quick = new HMEFMessage(stream);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test counts
|
* Test counts
|
||||||
*/
|
*/
|
||||||
|
@ -91,8 +91,9 @@ public final class TestPublisherTextExtractor extends TestCase {
|
|||||||
assertEquals( SAMPLE_TEXT, ext.getText() );
|
assertEquals( SAMPLE_TEXT, ext.getText() );
|
||||||
|
|
||||||
// And with NPOIFS
|
// And with NPOIFS
|
||||||
|
NPOIFSFileSystem fs = new NPOIFSFileSystem(sample);
|
||||||
HPBFDocument docNPOIFS = new HPBFDocument(
|
HPBFDocument docNPOIFS = new HPBFDocument(
|
||||||
new NPOIFSFileSystem(sample)
|
fs
|
||||||
);
|
);
|
||||||
ext = new PublisherTextExtractor(docNPOIFS);
|
ext = new PublisherTextExtractor(docNPOIFS);
|
||||||
assertEquals( SAMPLE_TEXT, ext.getText() );
|
assertEquals( SAMPLE_TEXT, ext.getText() );
|
||||||
@ -103,6 +104,7 @@ public final class TestPublisherTextExtractor extends TestCase {
|
|||||||
new FileInputStream(simple)
|
new FileInputStream(simple)
|
||||||
);
|
);
|
||||||
assertEquals( SIMPLE_TEXT, ext.getText() );
|
assertEquals( SIMPLE_TEXT, ext.getText() );
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,7 +349,8 @@ public final class TestExtractor extends POITestCase {
|
|||||||
// Open the two filesystems
|
// Open the two filesystems
|
||||||
DirectoryNode[] files = new DirectoryNode[2];
|
DirectoryNode[] files = new DirectoryNode[2];
|
||||||
files[0] = (new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"))).getRoot();
|
files[0] = (new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"))).getRoot();
|
||||||
files[1] = (new NPOIFSFileSystem(slTests.getFile("basic_test_ppt_file.ppt"))).getRoot();
|
NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(slTests.getFile("basic_test_ppt_file.ppt"));
|
||||||
|
files[1] = npoifsFileSystem.getRoot();
|
||||||
|
|
||||||
// Open directly
|
// Open directly
|
||||||
for(DirectoryNode dir : files) {
|
for(DirectoryNode dir : files) {
|
||||||
@ -363,6 +364,8 @@ public final class TestExtractor extends POITestCase {
|
|||||||
PowerPointExtractor extractor = new PowerPointExtractor(slideshow);
|
PowerPointExtractor extractor = new PowerPointExtractor(slideshow);
|
||||||
assertEquals(expectText, extractor.getText());
|
assertEquals(expectText, extractor.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npoifsFileSystem.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTable() throws Exception{
|
public void testTable() throws Exception{
|
||||||
|
@ -342,7 +342,8 @@ public final class TestWordExtractor extends TestCase {
|
|||||||
// Open the two filesystems
|
// Open the two filesystems
|
||||||
DirectoryNode[] files = new DirectoryNode[2];
|
DirectoryNode[] files = new DirectoryNode[2];
|
||||||
files[0] = (new POIFSFileSystem(docTests.openResourceAsStream("test2.doc"))).getRoot();
|
files[0] = (new POIFSFileSystem(docTests.openResourceAsStream("test2.doc"))).getRoot();
|
||||||
files[1] = (new NPOIFSFileSystem(docTests.getFile("test2.doc"))).getRoot();
|
NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(docTests.getFile("test2.doc"));
|
||||||
|
files[1] = npoifsFileSystem.getRoot();
|
||||||
|
|
||||||
// Open directly
|
// Open directly
|
||||||
for(DirectoryNode dir : files) {
|
for(DirectoryNode dir : files) {
|
||||||
@ -356,6 +357,8 @@ public final class TestWordExtractor extends TestCase {
|
|||||||
WordExtractor extractor = new WordExtractor(doc);
|
WordExtractor extractor = new WordExtractor(doc);
|
||||||
assertEquals(p_text1_block, extractor.getText());
|
assertEquals(p_text1_block, extractor.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
npoifsFileSystem.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,53 +21,51 @@ import java.lang.reflect.AccessibleObject;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.apache.poi.hwpf.HWPFDocFixture;
|
import org.apache.poi.hwpf.HWPFDocFixture;
|
||||||
|
|
||||||
public final class TestFileInformationBlock
|
public final class TestFileInformationBlock extends TestCase {
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
private FileInformationBlock _fileInformationBlock = null;
|
private FileInformationBlock _fileInformationBlock = null;
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite() throws Exception {
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
int size = _fileInformationBlock.getSize();
|
int size = _fileInformationBlock.getSize();
|
||||||
byte[] buf = new byte[size];
|
byte[] buf = new byte[size];
|
||||||
|
|
||||||
_fileInformationBlock.getFibBase().serialize(buf, 0);
|
_fileInformationBlock.getFibBase().serialize(buf, 0);
|
||||||
|
|
||||||
FileInformationBlock newFileInformationBlock =
|
FileInformationBlock newFileInformationBlock = new FileInformationBlock(
|
||||||
new FileInformationBlock(buf);
|
buf);
|
||||||
|
|
||||||
Field[] fields = FileInformationBlock.class.getSuperclass().getDeclaredFields();
|
Field[] fields = FileInformationBlock.class.getSuperclass()
|
||||||
|
.getDeclaredFields();
|
||||||
AccessibleObject.setAccessible(fields, true);
|
AccessibleObject.setAccessible(fields, true);
|
||||||
|
|
||||||
for (int x = 0; x < fields.length; x++)
|
for (int x = 0; x < fields.length; x++) {
|
||||||
{
|
assertEquals(fields[x].get(_fileInformationBlock),
|
||||||
assertEquals(fields[x].get(_fileInformationBlock), fields[x].get(newFileInformationBlock));
|
fields[x].get(newFileInformationBlock));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp()
|
assertNotNull(_fileInformationBlock.toString());
|
||||||
throws Exception
|
}
|
||||||
{
|
|
||||||
|
@Override
|
||||||
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
/** @todo verify the constructors */
|
/** @todo verify the constructors */
|
||||||
_hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
|
_hWPFDocFixture = new HWPFDocFixture(this,
|
||||||
|
HWPFDocFixture.DEFAULT_TEST_FILE);
|
||||||
|
|
||||||
_hWPFDocFixture.setUp();
|
_hWPFDocFixture.setUp();
|
||||||
_fileInformationBlock = _hWPFDocFixture._fib;
|
_fileInformationBlock = _hWPFDocFixture._fib;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown()
|
@Override
|
||||||
throws Exception
|
protected void tearDown() throws Exception {
|
||||||
{
|
|
||||||
_fileInformationBlock = null;
|
_fileInformationBlock = null;
|
||||||
_hWPFDocFixture.tearDown();
|
_hWPFDocFixture.tearDown();
|
||||||
|
|
||||||
_hWPFDocFixture = null;
|
_hWPFDocFixture = null;
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,21 +27,20 @@ import org.apache.poi.hwpf.HWPFDocument;
|
|||||||
import org.apache.poi.hwpf.HWPFTestDataSamples;
|
import org.apache.poi.hwpf.HWPFTestDataSamples;
|
||||||
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
|
import org.apache.poi.hwpf.model.io.HWPFFileSystem;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public final class TestTextPieceTable extends TestCase {
|
public final class TestTextPieceTable extends TestCase {
|
||||||
private HWPFDocFixture _hWPFDocFixture;
|
private HWPFDocFixture _hWPFDocFixture;
|
||||||
|
|
||||||
// private String dirname;
|
// private String dirname;
|
||||||
|
|
||||||
public void testReadWrite()
|
public void testReadWrite() throws Exception {
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
FileInformationBlock fib = _hWPFDocFixture._fib;
|
FileInformationBlock fib = _hWPFDocFixture._fib;
|
||||||
byte[] mainStream = _hWPFDocFixture._mainStream;
|
byte[] mainStream = _hWPFDocFixture._mainStream;
|
||||||
byte[] tableStream = _hWPFDocFixture._tableStream;
|
byte[] tableStream = _hWPFDocFixture._tableStream;
|
||||||
int fcMin = fib.getFibBase().getFcMin();
|
int fcMin = fib.getFibBase().getFcMin();
|
||||||
|
|
||||||
ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream, fib.getFcClx(), fcMin);
|
ComplexFileTable cft = new ComplexFileTable(mainStream, tableStream,
|
||||||
|
fib.getFcClx(), fcMin);
|
||||||
|
|
||||||
HWPFFileSystem fileSys = new HWPFFileSystem();
|
HWPFFileSystem fileSys = new HWPFFileSystem();
|
||||||
|
|
||||||
@ -52,7 +51,8 @@ public final class TestTextPieceTable extends TestCase {
|
|||||||
byte[] newTableStream = tableOut.toByteArray();
|
byte[] newTableStream = tableOut.toByteArray();
|
||||||
byte[] newMainStream = mainOut.toByteArray();
|
byte[] newMainStream = mainOut.toByteArray();
|
||||||
|
|
||||||
ComplexFileTable newCft = new ComplexFileTable(newMainStream, newTableStream, 0,0);
|
ComplexFileTable newCft = new ComplexFileTable(newMainStream,
|
||||||
|
newTableStream, 0, 0);
|
||||||
|
|
||||||
TextPieceTable oldTextPieceTable = cft.getTextPieceTable();
|
TextPieceTable oldTextPieceTable = cft.getTextPieceTable();
|
||||||
TextPieceTable newTextPieceTable = newCft.getTextPieceTable();
|
TextPieceTable newTextPieceTable = newCft.getTextPieceTable();
|
||||||
@ -61,11 +61,11 @@ public final class TestTextPieceTable extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that we do the positions correctly when
|
* Check that we do the positions correctly when working with pure-ascii
|
||||||
* working with pure-ascii
|
|
||||||
*/
|
*/
|
||||||
public void testAsciiParts() throws Exception {
|
public void testAsciiParts() throws Exception {
|
||||||
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("ThreeColHeadFoot.doc");
|
HWPFDocument doc = HWPFTestDataSamples
|
||||||
|
.openSampleFile("ThreeColHeadFoot.doc");
|
||||||
TextPieceTable tbl = doc.getTextTable();
|
TextPieceTable tbl = doc.getTextTable();
|
||||||
|
|
||||||
// All ascii, so stored in one big lump
|
// All ascii, so stored in one big lump
|
||||||
@ -76,8 +76,8 @@ public final class TestTextPieceTable extends TestCase {
|
|||||||
assertEquals(339, tp.getEnd());
|
assertEquals(339, tp.getEnd());
|
||||||
assertEquals(339, tp.characterLength());
|
assertEquals(339, tp.characterLength());
|
||||||
assertEquals(339, tp.bytesLength());
|
assertEquals(339, tp.bytesLength());
|
||||||
assertTrue(tp.getStringBuilder().toString().startsWith("This is a sample word document"));
|
assertTrue(tp.getStringBuilder().toString()
|
||||||
|
.startsWith("This is a sample word document"));
|
||||||
|
|
||||||
// Save and re-load
|
// Save and re-load
|
||||||
HWPFDocument docB = saveAndReload(doc);
|
HWPFDocument docB = saveAndReload(doc);
|
||||||
@ -90,22 +90,24 @@ public final class TestTextPieceTable extends TestCase {
|
|||||||
assertEquals(339, tp.getEnd());
|
assertEquals(339, tp.getEnd());
|
||||||
assertEquals(339, tp.characterLength());
|
assertEquals(339, tp.characterLength());
|
||||||
assertEquals(339, tp.bytesLength());
|
assertEquals(339, tp.bytesLength());
|
||||||
assertTrue(tp.getStringBuilder().toString().startsWith("This is a sample word document"));
|
assertTrue(tp.getStringBuilder().toString()
|
||||||
|
.startsWith("This is a sample word document"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that we do the positions correctly when
|
* Check that we do the positions correctly when working with a mix ascii,
|
||||||
* working with a mix ascii, unicode file
|
* unicode file
|
||||||
*/
|
*/
|
||||||
public void testUnicodeParts() throws Exception {
|
public void testUnicodeParts() throws Exception {
|
||||||
HWPFDocument doc = HWPFTestDataSamples.openSampleFile("HeaderFooterUnicode.doc");
|
HWPFDocument doc = HWPFTestDataSamples
|
||||||
|
.openSampleFile("HeaderFooterUnicode.doc");
|
||||||
TextPieceTable tbl = doc.getTextTable();
|
TextPieceTable tbl = doc.getTextTable();
|
||||||
|
|
||||||
// In three bits, split every 512 bytes
|
// In three bits, split every 512 bytes
|
||||||
assertEquals(3, tbl.getTextPieces().size());
|
assertEquals(3, tbl.getTextPieces().size());
|
||||||
TextPiece tpA = (TextPiece)tbl.getTextPieces().get(0);
|
TextPiece tpA = tbl.getTextPieces().get(0);
|
||||||
TextPiece tpB = (TextPiece)tbl.getTextPieces().get(1);
|
TextPiece tpB = tbl.getTextPieces().get(1);
|
||||||
TextPiece tpC = (TextPiece)tbl.getTextPieces().get(2);
|
TextPiece tpC = tbl.getTextPieces().get(2);
|
||||||
|
|
||||||
assertTrue(tpA.isUnicode());
|
assertTrue(tpA.isUnicode());
|
||||||
assertTrue(tpB.isUnicode());
|
assertTrue(tpB.isUnicode());
|
||||||
@ -126,15 +128,14 @@ public final class TestTextPieceTable extends TestCase {
|
|||||||
assertEquals(512, tpC.getStart());
|
assertEquals(512, tpC.getStart());
|
||||||
assertEquals(531, tpC.getEnd());
|
assertEquals(531, tpC.getEnd());
|
||||||
|
|
||||||
|
|
||||||
// Save and re-load
|
// Save and re-load
|
||||||
HWPFDocument docB = saveAndReload(doc);
|
HWPFDocument docB = saveAndReload(doc);
|
||||||
tbl = docB.getTextTable();
|
tbl = docB.getTextTable();
|
||||||
|
|
||||||
assertEquals(3, tbl.getTextPieces().size());
|
assertEquals(3, tbl.getTextPieces().size());
|
||||||
tpA = (TextPiece)tbl.getTextPieces().get(0);
|
tpA = tbl.getTextPieces().get(0);
|
||||||
tpB = (TextPiece)tbl.getTextPieces().get(1);
|
tpB = tbl.getTextPieces().get(1);
|
||||||
tpC = (TextPiece)tbl.getTextPieces().get(2);
|
tpC = tbl.getTextPieces().get(2);
|
||||||
|
|
||||||
assertTrue(tpA.isUnicode());
|
assertTrue(tpA.isUnicode());
|
||||||
assertTrue(tpB.isUnicode());
|
assertTrue(tpB.isUnicode());
|
||||||
@ -160,28 +161,27 @@ public final class TestTextPieceTable extends TestCase {
|
|||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
doc.write(baos);
|
doc.write(baos);
|
||||||
|
|
||||||
return new HWPFDocument(
|
return new HWPFDocument(new ByteArrayInputStream(baos.toByteArray()));
|
||||||
new ByteArrayInputStream(baos.toByteArray())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp()
|
@Override
|
||||||
throws Exception
|
protected void setUp() throws Exception {
|
||||||
{
|
|
||||||
super.setUp();
|
super.setUp();
|
||||||
System.setProperty( "org.apache.poi.hwpf.preserveTextTable", Boolean.TRUE.toString() );
|
System.setProperty("org.apache.poi.hwpf.preserveTextTable",
|
||||||
|
Boolean.TRUE.toString());
|
||||||
|
|
||||||
_hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
|
_hWPFDocFixture = new HWPFDocFixture(this,
|
||||||
|
HWPFDocFixture.DEFAULT_TEST_FILE);
|
||||||
_hWPFDocFixture.setUp();
|
_hWPFDocFixture.setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown()
|
@Override
|
||||||
throws Exception
|
protected void tearDown() throws Exception {
|
||||||
{
|
|
||||||
_hWPFDocFixture.tearDown();
|
_hWPFDocFixture.tearDown();
|
||||||
_hWPFDocFixture = null;
|
_hWPFDocFixture = null;
|
||||||
|
|
||||||
System.setProperty( "org.apache.poi.hwpf.preserveTextTable", Boolean.FALSE.toString() );
|
System.setProperty("org.apache.poi.hwpf.preserveTextTable",
|
||||||
|
Boolean.FALSE.toString());
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,11 +396,15 @@ public class TestBugs extends TestCase
|
|||||||
// document as text file using encoding UTF-8)
|
// document as text file using encoding UTF-8)
|
||||||
InputStream is = POIDataSamples.getDocumentInstance()
|
InputStream is = POIDataSamples.getDocumentInstance()
|
||||||
.openResourceAsStream( "Bug47742-text.txt" );
|
.openResourceAsStream( "Bug47742-text.txt" );
|
||||||
|
try {
|
||||||
byte[] expectedBytes = IOUtils.toByteArray( is );
|
byte[] expectedBytes = IOUtils.toByteArray( is );
|
||||||
String expectedText = new String( expectedBytes, "utf-8" )
|
String expectedText = new String( expectedBytes, "utf-8" )
|
||||||
.substring( 1 ); // strip-off the unicode marker
|
.substring( 1 ); // strip-off the unicode marker
|
||||||
|
|
||||||
assertEquals( expectedText, foundText );
|
assertEquals( expectedText, foundText );
|
||||||
|
} finally {
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,7 +268,7 @@ public class TestWrite
|
|||||||
assertNotNull(psa[0]);
|
assertNotNull(psa[0]);
|
||||||
assertTrue(psa[0].isSummaryInformation());
|
assertTrue(psa[0].isSummaryInformation());
|
||||||
|
|
||||||
final Section s = (Section) (psa[0].getSections().get(0));
|
final Section s = (psa[0].getSections().get(0));
|
||||||
Object p1 = s.getProperty(PropertyIDMap.PID_AUTHOR);
|
Object p1 = s.getProperty(PropertyIDMap.PID_AUTHOR);
|
||||||
Object p2 = s.getProperty(PropertyIDMap.PID_TITLE);
|
Object p2 = s.getProperty(PropertyIDMap.PID_TITLE);
|
||||||
assertEquals(AUTHOR, p1);
|
assertEquals(AUTHOR, p1);
|
||||||
@ -349,11 +349,11 @@ public class TestWrite
|
|||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
assertNotNull(psa[0]);
|
assertNotNull(psa[0]);
|
||||||
Section s = (Section) (psa[0].getSections().get(0));
|
Section s = (psa[0].getSections().get(0));
|
||||||
assertEquals(s.getFormatID(), formatID);
|
assertEquals(s.getFormatID(), formatID);
|
||||||
Object p = s.getProperty(2);
|
Object p = s.getProperty(2);
|
||||||
assertEquals(SECTION1, p);
|
assertEquals(SECTION1, p);
|
||||||
s = (Section) (psa[0].getSections().get(1));
|
s = (psa[0].getSections().get(1));
|
||||||
p = s.getProperty(2);
|
p = s.getProperty(2);
|
||||||
assertEquals(SECTION2, p);
|
assertEquals(SECTION2, p);
|
||||||
}
|
}
|
||||||
@ -584,7 +584,7 @@ public class TestWrite
|
|||||||
|
|
||||||
PropertySet psr = new PropertySet(bytes);
|
PropertySet psr = new PropertySet(bytes);
|
||||||
assertTrue(psr.isSummaryInformation());
|
assertTrue(psr.isSummaryInformation());
|
||||||
Section sr = (Section) psr.getSections().get(0);
|
Section sr = psr.getSections().get(0);
|
||||||
String title = (String) sr.getProperty(PropertyIDMap.PID_TITLE);
|
String title = (String) sr.getProperty(PropertyIDMap.PID_TITLE);
|
||||||
assertEquals(TITLE, title);
|
assertEquals(TITLE, title);
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ final class Util {
|
|||||||
final String[] poiFiles)
|
final String[] poiFiles)
|
||||||
throws FileNotFoundException, IOException
|
throws FileNotFoundException, IOException
|
||||||
{
|
{
|
||||||
final List files = new ArrayList();
|
final List<POIFile> files = new ArrayList<POIFile>();
|
||||||
POIFSReader r = new POIFSReader();
|
POIFSReader r = new POIFSReader();
|
||||||
POIFSReaderListener pfl = new POIFSReaderListener()
|
POIFSReaderListener pfl = new POIFSReaderListener()
|
||||||
{
|
{
|
||||||
@ -170,7 +170,7 @@ final class Util {
|
|||||||
r.read(new FileInputStream(poiFs));
|
r.read(new FileInputStream(poiFs));
|
||||||
POIFile[] result = new POIFile[files.size()];
|
POIFile[] result = new POIFile[files.size()];
|
||||||
for (int i = 0; i < result.length; i++)
|
for (int i = 0; i < result.length; i++)
|
||||||
result[i] = (POIFile) files.get(i);
|
result[i] = files.get(i);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ final class Util {
|
|||||||
public static POIFile[] readPropertySets(final File poiFs)
|
public static POIFile[] readPropertySets(final File poiFs)
|
||||||
throws FileNotFoundException, IOException
|
throws FileNotFoundException, IOException
|
||||||
{
|
{
|
||||||
final List files = new ArrayList(7);
|
final List<POIFile> files = new ArrayList<POIFile>(7);
|
||||||
final POIFSReader r = new POIFSReader();
|
final POIFSReader r = new POIFSReader();
|
||||||
POIFSReaderListener pfl = new POIFSReaderListener()
|
POIFSReaderListener pfl = new POIFSReaderListener()
|
||||||
{
|
{
|
||||||
|
@ -111,6 +111,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
|
for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
|
||||||
assertEquals(512, fs.getBigBlockSize());
|
assertEquals(512, fs.getBigBlockSize());
|
||||||
}
|
}
|
||||||
|
fsA.close();
|
||||||
|
fsB.close();
|
||||||
|
|
||||||
// Now with a simple 4096 block file
|
// Now with a simple 4096 block file
|
||||||
fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
|
fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
|
||||||
@ -118,6 +120,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
|
for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB}) {
|
||||||
assertEquals(4096, fs.getBigBlockSize());
|
assertEquals(4096, fs.getBigBlockSize());
|
||||||
}
|
}
|
||||||
|
fsA.close();
|
||||||
|
fsB.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -186,6 +190,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
assertEquals(i+1, ministore.getNextBlock(i));
|
assertEquals(i+1, ministore.getNextBlock(i));
|
||||||
}
|
}
|
||||||
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50));
|
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50));
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now with a simple 4096 block file
|
// Now with a simple 4096 block file
|
||||||
@ -252,6 +258,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
assertEquals(i+1, ministore.getNextBlock(i));
|
assertEquals(i+1, ministore.getNextBlock(i));
|
||||||
}
|
}
|
||||||
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50));
|
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(50));
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,6 +303,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
for(int i=100; i<fs.getBigBlockSizeDetails().getBATEntriesPerBlock(); i++) {
|
for(int i=100; i<fs.getBigBlockSizeDetails().getBATEntriesPerBlock(); i++) {
|
||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(i));
|
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quick check on 4096 byte blocks too
|
// Quick check on 4096 byte blocks too
|
||||||
@ -311,6 +321,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
assertEquals(i+1, fs.getNextBlock(i));
|
assertEquals(i+1, fs.getNextBlock(i));
|
||||||
}
|
}
|
||||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(11));
|
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(11));
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +360,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quick check on 4096 byte blocks too
|
// Quick check on 4096 byte blocks too
|
||||||
@ -380,6 +394,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,6 +607,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
// Look inside another
|
// Look inside another
|
||||||
DirectoryEntry imageD = (DirectoryEntry)image;
|
DirectoryEntry imageD = (DirectoryEntry)image;
|
||||||
assertEquals(7, imageD.getEntryCount());
|
assertEquals(7, imageD.getEntryCount());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,6 +653,8 @@ public final class TestNPOIFSFileSystem {
|
|||||||
ps = PropertySetFactory.create(inp);
|
ps = PropertySetFactory.create(inp);
|
||||||
DocumentSummaryInformation dinf = (DocumentSummaryInformation)ps;
|
DocumentSummaryInformation dinf = (DocumentSummaryInformation)ps;
|
||||||
assertEquals(131333, dinf.getOSVersion());
|
assertEquals(131333, dinf.getOSVersion());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ import org.apache.poi.poifs.common.POIFSConstants;
|
|||||||
/**
|
/**
|
||||||
* Tests for the Mini Store in the NIO POIFS
|
* Tests for the Mini Store in the NIO POIFS
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("resource")
|
|
||||||
public final class TestNPOIFSMiniStore extends TestCase {
|
public final class TestNPOIFSMiniStore extends TestCase {
|
||||||
private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance();
|
private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance();
|
||||||
|
|
||||||
@ -103,6 +102,8 @@ public final class TestNPOIFSMiniStore extends TestCase {
|
|||||||
for(int i=181; i<fs.getBigBlockSizeDetails().getBATEntriesPerBlock(); i++) {
|
for(int i=181; i<fs.getBigBlockSizeDetails().getBATEntriesPerBlock(); i++) {
|
||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(i));
|
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +169,8 @@ public final class TestNPOIFSMiniStore extends TestCase {
|
|||||||
assertEquals((byte)0, b.get());
|
assertEquals((byte)0, b.get());
|
||||||
assertEquals((byte)0, b.get());
|
assertEquals((byte)0, b.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +201,8 @@ public final class TestNPOIFSMiniStore extends TestCase {
|
|||||||
// Allocate it, then ask again
|
// Allocate it, then ask again
|
||||||
ministore.setNextBlock(181, POIFSConstants.END_OF_CHAIN);
|
ministore.setNextBlock(181, POIFSConstants.END_OF_CHAIN);
|
||||||
assertEquals(182, ministore.getFreeBlock());
|
assertEquals(182, ministore.getFreeBlock());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -240,6 +245,8 @@ public final class TestNPOIFSMiniStore extends TestCase {
|
|||||||
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(255)); // 2nd SBAT
|
assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(255)); // 2nd SBAT
|
||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(256)); // 3rd SBAT
|
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(256)); // 3rd SBAT
|
||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(257)); // 3rd SBAT
|
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(257)); // 3rd SBAT
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,5 +329,7 @@ public final class TestNPOIFSMiniStore extends TestCase {
|
|||||||
for(int i=193; i<256; i++) {
|
for(int i=193; i<256; i++) {
|
||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(i));
|
assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
assertEquals((byte)0x00, b.get());
|
assertEquals((byte)0x00, b.get());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,6 +105,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
assertEquals((byte)0x00, b98.get());
|
assertEquals((byte)0x00, b98.get());
|
||||||
assertEquals((byte)0x00, b98.get());
|
assertEquals((byte)0x00, b98.get());
|
||||||
assertEquals((byte)0x00, b98.get());
|
assertEquals((byte)0x00, b98.get());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,6 +161,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
assertEquals((byte)0x01, b22.get());
|
assertEquals((byte)0x01, b22.get());
|
||||||
assertEquals((byte)0x02, b22.get());
|
assertEquals((byte)0x02, b22.get());
|
||||||
assertEquals((byte)0x00, b22.get());
|
assertEquals((byte)0x00, b22.get());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -211,6 +217,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
assertEquals((byte)0x00, b2.get());
|
assertEquals((byte)0x00, b2.get());
|
||||||
assertEquals((byte)0x46, b2.get());
|
assertEquals((byte)0x46, b2.get());
|
||||||
assertEquals((byte)0x00, b2.get());
|
assertEquals((byte)0x00, b2.get());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,6 +257,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
// Good, it was detected
|
// Good, it was detected
|
||||||
}
|
}
|
||||||
assertEquals(true, i.hasNext());
|
assertEquals(true, i.hasNext());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -304,6 +314,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
assertEquals((byte)0x00, b180.get());
|
assertEquals((byte)0x00, b180.get());
|
||||||
assertEquals((byte)0x00, b180.get());
|
assertEquals((byte)0x00, b180.get());
|
||||||
assertEquals((byte)0x80, b180.get());
|
assertEquals((byte)0x80, b180.get());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -334,6 +346,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
byte exp = (byte)(i%256);
|
byte exp = (byte)(i%256);
|
||||||
assertEquals(exp, data[i]);
|
assertEquals(exp, data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -373,6 +387,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
byte exp = (byte)(i%256);
|
byte exp = (byte)(i%256);
|
||||||
assertEquals(exp, data[i]);
|
assertEquals(exp, data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -417,6 +433,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
assertEquals(3, count);
|
assertEquals(3, count);
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -507,6 +525,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(102));
|
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(102));
|
||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(103));
|
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(103));
|
||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(104));
|
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(104));
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -547,6 +567,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
assertEquals(130, fs.getNextBlock(129));
|
assertEquals(130, fs.getNextBlock(129));
|
||||||
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(130));
|
assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(130));
|
||||||
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(131));
|
assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(131));
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -600,6 +622,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
assertEquals(5, count);
|
assertEquals(5, count);
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -790,6 +814,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
assertEquals((byte)0x42, b183.get(1));
|
assertEquals((byte)0x42, b183.get(1));
|
||||||
assertEquals((byte)0x81, b184.get(0));
|
assertEquals((byte)0x81, b184.get(0));
|
||||||
assertEquals((byte)0x82, b184.get(1));
|
assertEquals((byte)0x82, b184.get(1));
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -823,6 +849,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
stream.updateContents(data);
|
stream.updateContents(data);
|
||||||
fail("Loop should have been detected but wasn't!");
|
fail("Loop should have been detected but wasn't!");
|
||||||
} catch(IllegalStateException e) {}
|
} catch(IllegalStateException e) {}
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -889,6 +917,8 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(false, it.hasNext());
|
assertEquals(false, it.hasNext());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1079,5 +1109,7 @@ public final class TestNPOIFSStream extends TestCase {
|
|||||||
normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
|
normal = (DocumentEntry)fs.getRoot().getEntry("Normal");
|
||||||
assertEquals(4096, normal.getSize());
|
assertEquals(4096, normal.getSize());
|
||||||
assertEquals(4096, ((DocumentNode)normal).getProperty().getSize());
|
assertEquals(4096, ((DocumentNode)normal).getProperty().getSize());
|
||||||
|
|
||||||
|
fs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user