diff options
Diffstat (limited to 'src/ooxml')
5 files changed, 66 insertions, 28 deletions
diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java index 4e132dafbd..a315493781 100644 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java @@ -145,21 +145,33 @@ public interface Cell { void setCellValue(Calendar value); /** - * set a string value for the cell. Please note that if you are using - * full 16 bit unicode you should call <code>setEncoding()</code> first. + * Set a rich string value for the cell. * * @param value value to set the cell to. For formulas we'll set the formula * string, for String cells we'll set its value. For other types we will * 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. */ - void setCellValue(RichTextString value); + /** + * Set a string value for the cell. + * + * @param value value to set the cell to. For formulas we'll set the formula + * string, for String cells we'll set its value. For other types we will + * 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. + */ void setCellValue(String value); + /** + * Set a formula value for the cell. + */ void setCellFormula(String formula); + /** + * Get the formula value of the cell. + */ String getCellFormula(); /** diff --git a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java index 12c6a6a0c1..bd500d56ae 100644 --- a/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java +++ b/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java @@ -409,7 +409,6 @@ public interface Sheet extends Iterable<Row> { * Additionally shifts merged regions that are completely defined in these * rows (ie. merged 2 cells on a row to be shifted). * <p> - * TODO Might want to add bounds checking here * @param startRow the row to start shifting * @param endRow the row to end shifting * @param n the number of rows to shift @@ -542,14 +541,6 @@ public interface Sheet extends Iterable<Row> { void removeColumnBreak(short column); /** - * Creates the toplevel drawing patriarch. This will have the effect of - * removing any existing drawings on this sheet. - * - * @return The new patriarch. - */ - //Patriarch createDrawingPatriarch(); - - /** * Expands or collapses a column group. * * @param columnNumber One of the columns in the group. @@ -567,10 +558,28 @@ public interface Sheet extends Iterable<Row> { void ungroupColumn(short fromColumn, short toColumn); + /** + * Tie a range of rows together so that they can be collapsed or expanded + * + * @param fromRow start row (0-based) + * @param toRow end row (0-based) + */ void groupRow(int fromRow, int toRow); + /** + * Ungroup a range of rows that were previously groupped + * + * @param fromRow start row (0-based) + * @param toRow end row (0-based) + */ void ungroupRow(int fromRow, int toRow); + /** + * Set view state of a groupped range of rows + * + * @param row start row of a groupped range of rows (0-based) + * @param collapse whether to expand/collapse the detail rows + */ void setRowGroupCollapsed(int row, boolean collapse); /** @@ -599,6 +608,11 @@ public interface Sheet extends Iterable<Row> { */ Comment getCellComment(int row, int column); + /** + * Creates the top-level drawing patriarch. + * + * @return The new drawing patriarch. + */ Drawing createDrawingPatriarch(); } diff --git a/src/ooxml/java/org/apache/poi/xssf/dev/XSSFSave.java b/src/ooxml/java/org/apache/poi/xssf/dev/XSSFSave.java index 148a02fcb2..10a4b4755e 100755 --- a/src/ooxml/java/org/apache/poi/xssf/dev/XSSFSave.java +++ b/src/ooxml/java/org/apache/poi/xssf/dev/XSSFSave.java @@ -32,7 +32,7 @@ public class XSSFSave { XSSFWorkbook wb = new XSSFWorkbook(args[i]);
int sep = args[i].lastIndexOf('.');
- String outfile = args[i].substring(0, sep) + "-save.xlsx";
+ String outfile = args[i].substring(0, sep) + "-save.xls" + (wb.isMacroEnabled() ? "m" : "x");
FileOutputStream out = new FileOutputStream(outfile);
wb.write(out);
out.close();
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 24a3f252f0..7613c87cf1 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -952,20 +952,26 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { setSheetFormatPrOutlineLevelCol(); } + /** + * Tie a range of cell together so that they can be collapsed or expanded + * + * @param fromRow start row (0-based) + * @param toRow end row (0-based) + */ public void groupRow(int fromRow, int toRow) { - for(int i=fromRow;i<=toRow;i++){ - XSSFRow xrow = getRow(i-1); - if(xrow == null){//create a new Row - xrow = createRow(i-1); + for (int i = fromRow; i <= toRow; i++) { + XSSFRow xrow = getRow(i); + if (xrow == null) { + xrow = createRow(i); } - CTRow ctrow=xrow.getCTRow(); - short outlineLevel=ctrow.getOutlineLevel(); - ctrow.setOutlineLevel((short)(outlineLevel+1)); - } - setSheetFormatPrOutlineLevelRow(); + CTRow ctrow = xrow.getCTRow(); + short outlineLevel = ctrow.getOutlineLevel(); + ctrow.setOutlineLevel((short) (outlineLevel + 1)); + } + setSheetFormatPrOutlineLevelRow(); } - private short getMaxOutlineLevelRows(){ + private short getMaxOutlineLevelRows(){ short outlineLevel=0; for(Row r : rows.values()){ XSSFRow xrow=(XSSFRow)r; @@ -1478,9 +1484,15 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { setSheetFormatPrOutlineLevelCol(); } + /** + * Ungroup a range of rows that were previously groupped + * + * @param fromRow start row (0-based) + * @param toRow end row (0-based) + */ public void ungroupRow(int fromRow, int toRow) { for (int i = fromRow; i <= toRow; i++) { - XSSFRow xrow = getRow(i - 1); + XSSFRow xrow = getRow(i); if (xrow != null) { CTRow ctrow = xrow.getCTRow(); short outlinelevel = ctrow.getOutlineLevel(); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 62d2b7d989..dd0446c9dd 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -789,19 +789,19 @@ public class TestXSSFSheet extends TestCase { //one level sheet.groupRow(9,10); assertEquals(2,sheet.getPhysicalNumberOfRows()); - CTRow ctrow = sheet.getRow(8).getCTRow(); + CTRow ctrow = sheet.getRow(9).getCTRow(); assertNotNull(ctrow); - assertEquals(9,ctrow.getR()); + assertEquals(10,ctrow.getR()); assertEquals(1, ctrow.getOutlineLevel()); assertEquals(1,sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow()); //two level sheet.groupRow(10,13); assertEquals(5,sheet.getPhysicalNumberOfRows()); - ctrow = sheet.getRow(9).getCTRow(); + ctrow = sheet.getRow(10).getCTRow(); assertNotNull(ctrow); - assertEquals(10,ctrow.getR()); + assertEquals(11,ctrow.getR()); assertEquals(2, ctrow.getOutlineLevel()); assertEquals(2,sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow()); |