</devs>
<!-- Don't forget to update status.xml too! -->
- <release version="3.5-beta6" date="2008-??-??">
+ <release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="add">46703 - added setDisplayZeros / isDisplayZeros to common interface org.apache.poi.ss.usermodel.Sheet</action>
+ <action dev="POI-DEVELOPERS" type="add">46708 - added getMergedRegion(int) to common interface org.apache.poi.ss.usermodel.Sheet</action>
<action dev="POI-DEVELOPERS" type="fix">fixed Sheet.autoSizeColumn() to use cached formula values when processing formula cells </action>
<action dev="POI-DEVELOPERS" type="fix">Fixed formula parser to handle names with backslashes</action>
<action dev="POI-DEVELOPERS" type="add">46660 - added Workbook getHidden() and setHidden(boolean)</action>
<action dev="POI-DEVELOPERS" type="fix">46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX</action>
<action dev="POI-DEVELOPERS" type="fix">46627 - Fixed offset of added images if Pictures stream contains pictures with zero length</action>
</release>
- <release version="3.5-beta5" date="2008-02-19">
+ <release version="3.5-beta5" date="2009-02-19">
<action dev="POI-DEVELOPERS" type="fix">46536 - When shifting rows, update formulas on that sheet to point to the new location of those rows</action>
<action dev="POI-DEVELOPERS" type="fix">46663 - Fixed XSSFSheet.shiftRows to properly update references of the shifted cells</action>
<action dev="POI-DEVELOPERS" type="fix">46535 - Remove reference from calculation chain when a formula is deleted</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
- <release version="3.5-beta6" date="2008-??-??">
+ <release version="3.5-beta6" date="2009-??-??">
+ <action dev="POI-DEVELOPERS" type="add">46703 - added setDisplayZeros / isDisplayZeros to common interface org.apache.poi.ss.usermodel.Sheet</action>
+ <action dev="POI-DEVELOPERS" type="add">46708 - added getMergedRegion(int) to common interface org.apache.poi.ss.usermodel.Sheet</action>
<action dev="POI-DEVELOPERS" type="fix">fixed Sheet.autoSizeColumn() to use cached formula values when processing formula cells </action>
<action dev="POI-DEVELOPERS" type="fix">Fixed formula parser to handle names with backslashes</action>
<action dev="POI-DEVELOPERS" type="add">46660 - added Workbook getHidden() and setHidden(boolean)</action>
<action dev="POI-DEVELOPERS" type="fix">46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX</action>
<action dev="POI-DEVELOPERS" type="fix">46627 - Fixed offset of added images if Pictures stream contains pictures with zero length</action>
</release>
- <release version="3.5-beta5" date="2008-02-19">
+ <release version="3.5-beta5" date="2009-02-19">
<action dev="POI-DEVELOPERS" type="fix">46536 - When shifting rows, update formulas on that sheet to point to the new location of those rows</action>
<action dev="POI-DEVELOPERS" type="fix">46663 - Fixed XSSFSheet.shiftRows to properly update references of the shifted cells</action>
<action dev="POI-DEVELOPERS" type="fix">46535 - Remove reference from calculation chain when a formula is deleted</action>
.getDisplayGuts();
}
+
+ /**
+ * Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value.
+ * When false, cells with zero value appear blank instead of showing the number zero.
+ * <p>
+ * In Excel 2003 this option can be changed in the Options dialog on the View tab.
+ * </p>
+ * @return whether all zero values on the worksheet are displayed
+ */
+ public boolean isDisplayZeros(){
+ return _sheet.getWindowTwo().getDisplayZeros();
+ }
+
+ /**
+ * Set whether the window should show 0 (zero) in cells containing zero value.
+ * When false, cells with zero value appear blank instead of showing the number zero.
+ * <p>
+ * In Excel 2003 this option can be set in the Options dialog on the View tab.
+ * </p>
+ * @param value whether to display or hide all zero values on the worksheet
+ */
+ public void setDisplayZeros(boolean value){
+ _sheet.getWindowTwo().setDisplayZeros(value);
+ }
+
/**
* fit to page option is on
* @return fit or not
*/
int getNumMergedRegions();
+ /**
+ * Returns the merged region at the specified index
+ *
+ * @return the merged region at the specified index
+ */
+ public CellRangeAddress getMergedRegion(int index);
+
/**
* Returns an iterator of the physical rows
*
*/
void setDisplayGuts(boolean value);
+ /**
+ * Set whether the window should show 0 (zero) in cells containing zero value.
+ * When false, cells with zero value appear blank instead of showing the number zero.
+ *
+ * @param value whether to display or hide all zero values on the worksheet
+ */
+ void setDisplayZeros(boolean value);
+
+
+ /**
+ * Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value.
+ * When false, cells with zero value appear blank instead of showing the number zero.
+ *
+ * @return whether all zero values on the worksheet are displayed
+ */
+ boolean isDisplayZeros();
+
/**
* Flag indicating whether the Fit to Page print option is enabled.
*
outlinePr.setShowOutlineSymbols(value);
}
+ /**
+ * Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value.
+ * When false, cells with zero value appear blank instead of showing the number zero.
+ *
+ * @return whether all zero values on the worksheet are displayed
+ */
+ public boolean isDisplayZeros(){
+ CTSheetView view = getDefaultSheetView();
+ return view == null ? true : view.getShowZeros();
+ }
+
+ /**
+ * Set whether the window should show 0 (zero) in cells containing zero value.
+ * When false, cells with zero value appear blank instead of showing the number zero.
+ *
+ * @param value whether to display or hide all zero values on the worksheet
+ */
+ public void setDisplayZeros(boolean value){
+ CTSheetView view = getSheetTypeSheetView();
+ view.setShowZeros(value);
+ }
+
/**
* Gets the first row on the sheet
*
--- /dev/null
+/* ====================================================================\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+package org.apache.poi.xssf;\r
+\r
+import org.apache.poi.ss.ITestDataProvider;\r
+import org.apache.poi.ss.usermodel.Workbook;\r
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;\r
+\r
+/**\r
+ * @author Yegor Kozlov\r
+ */\r
+public final class XSSFITestDataProvider implements ITestDataProvider {\r
+\r
+ public XSSFWorkbook openSampleWorkbook(String sampleFileName) {\r
+ return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);\r
+ }\r
+\r
+ public XSSFWorkbook writeOutAndReadBack(Workbook original) {\r
+ if(!(original instanceof XSSFWorkbook)) {\r
+ throw new IllegalArgumentException("Expected an instance of XSSFWorkbook");\r
+ }\r
+\r
+ return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original);\r
+ }\r
+\r
+ public XSSFWorkbook createWorkbook(){\r
+ return new XSSFWorkbook();\r
+ }\r
+\r
+ private XSSFITestDataProvider(){}\r
+ private static XSSFITestDataProvider inst = new XSSFITestDataProvider();\r
+ public static XSSFITestDataProvider getInstance(){\r
+ return inst;\r
+ }\r
+}\r
package org.apache.poi.xssf.usermodel;\r
\r
import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;\r
-import org.apache.poi.ss.usermodel.Workbook;\r
-import org.apache.poi.xssf.XSSFTestDataSamples;\r
+import org.apache.poi.ss.ITestDataProvider;\r
+import org.apache.poi.xssf.XSSFITestDataProvider;\r
\r
/**\r
* @author Yegor Kozlov\r
public class TestSheetShiftRows extends BaseTestSheetShiftRows {\r
\r
@Override\r
- protected Workbook openSampleWorkbook(String sampleFileName) {\r
- return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);\r
- }\r
-\r
- @Override\r
- protected Workbook writeOutAndReadBack(Workbook wb) {\r
- return XSSFTestDataSamples.writeOutAndReadBack(wb);\r
- }\r
-\r
- @Override\r
- protected Workbook createWorkbook() {\r
- return new XSSFWorkbook();\r
+ protected ITestDataProvider getTestDataProvider(){\r
+ return XSSFITestDataProvider.getInstance();\r
}\r
\r
public void testShiftRows() {\r
assertEquals(500, sh2.getColumnWidth(0));
assertEquals(sh1.getColumnWidth(0), sh2.getColumnWidth(0));
}
+
+ /**
+ * Tests the display of gridlines, formulas, and rowcolheadings.
+ * @author Shawn Laubach (slaubach at apache dot org)
+ */
+ public void testDisplayOptions() {
+ Workbook wb = new XSSFWorkbook();
+ Sheet sheet = wb.createSheet();
+
+ assertEquals(sheet.isDisplayGridlines(), true);
+ assertEquals(sheet.isDisplayRowColHeadings(), true);
+ assertEquals(sheet.isDisplayFormulas(), false);
+ assertEquals(sheet.isDisplayZeros(), true);
+
+ sheet.setDisplayGridlines(false);
+ sheet.setDisplayRowColHeadings(false);
+ sheet.setDisplayFormulas(true);
+ sheet.setDisplayZeros(false);
+
+ wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+ sheet = wb.getSheetAt(0);
+
+ assertEquals(sheet.isDisplayGridlines(), false);
+ assertEquals(sheet.isDisplayRowColHeadings(), false);
+ assertEquals(sheet.isDisplayFormulas(), true);
+ assertEquals(sheet.isDisplayZeros(), false);
+ }
+
}
--- /dev/null
+/* ====================================================================\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+\r
+package org.apache.poi.hssf;\r
+\r
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;\r
+import org.apache.poi.ss.ITestDataProvider;\r
+import org.apache.poi.ss.usermodel.Workbook;\r
+\r
+/**\r
+ * @author Yegor Kozlov\r
+ */\r
+public final class HSSFITestDataProvider implements ITestDataProvider {\r
+\r
+ public HSSFWorkbook openSampleWorkbook(String sampleFileName) {\r
+ return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);\r
+ }\r
+\r
+ public HSSFWorkbook writeOutAndReadBack(Workbook original) {\r
+ if(!(original instanceof HSSFWorkbook)) {\r
+ throw new IllegalArgumentException("Expected an instance of HSSFWorkbook");\r
+ }\r
+\r
+ return HSSFTestDataSamples.writeOutAndReadBack((HSSFWorkbook)original);\r
+ }\r
+\r
+ public HSSFWorkbook createWorkbook(){\r
+ return new HSSFWorkbook();\r
+ }\r
+\r
+ private HSSFITestDataProvider(){}\r
+ private static HSSFITestDataProvider inst = new HSSFITestDataProvider();\r
+ public static HSSFITestDataProvider getInstance(){\r
+ return inst;\r
+ }\r
+}
\ No newline at end of file
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
- wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
- sheet = wb.getSheetAt(0);
-
assertEquals(sheet.isDisplayGridlines(), true);
assertEquals(sheet.isDisplayRowColHeadings(), true);
assertEquals(sheet.isDisplayFormulas(), false);
+ assertEquals(sheet.isDisplayZeros(), true);
sheet.setDisplayGridlines(false);
sheet.setDisplayRowColHeadings(false);
sheet.setDisplayFormulas(true);
+ sheet.setDisplayZeros(false);
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
sheet = wb.getSheetAt(0);
assertEquals(sheet.isDisplayGridlines(), false);
assertEquals(sheet.isDisplayRowColHeadings(), false);
assertEquals(sheet.isDisplayFormulas(), true);
+ assertEquals(sheet.isDisplayZeros(), false);
}
package org.apache.poi.hssf.usermodel;
-import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
/**
*/
public final class TestSheetShiftRows extends BaseTestSheetShiftRows {
- @Override
- protected Workbook openSampleWorkbook(String sampleFileName) {
- return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);
- }
- @Override
- protected Workbook writeOutAndReadBack(Workbook wb) {
- if (wb instanceof HSSFWorkbook) {
- return HSSFTestDataSamples.writeOutAndReadBack((HSSFWorkbook) wb);
- }
- throw new IllegalArgumentException("bad workbook type (" + wb.getClass().getName() + ")");
- }
-
- @Override
- protected Workbook createWorkbook() {
- return new HSSFWorkbook();
- }
+ @Override
+ protected HSSFITestDataProvider getTestDataProvider(){
+ return HSSFITestDataProvider.getInstance();
+ }
public void testShiftRows() {
baseTestShiftRows("SimpleMultiCell.xls");
--- /dev/null
+/* ====================================================================\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+package org.apache.poi.ss;\r
+\r
+import org.apache.poi.ss.usermodel.Workbook;\r
+\r
+/**\r
+ * Incapsulates a provider of test data for common HSSF / XSSF tests.\r
+ */\r
+public interface ITestDataProvider {\r
+ /**\r
+ * Override to provide HSSF / XSSF specific way for re-serialising a workbook\r
+ *\r
+ * @param wb the workbook to re-serialize\r
+ * @return the re-serialized workbook\r
+ */\r
+ Workbook writeOutAndReadBack(Workbook wb);\r
+\r
+ /**\r
+ * Override to provide way of loading HSSF / XSSF sample workbooks\r
+ *\r
+ * @param sampleFileName the file name to load\r
+ * @return an instance of Workbook loaded from the supplied file name\r
+ */\r
+ Workbook openSampleWorkbook(String sampleFileName);\r
+\r
+ /**\r
+ * Override to provide way of creating HSSF / XSSF workbooks\r
+ * @return an instance of Workbook\r
+ */\r
+ Workbook createWorkbook();\r
+\r
+}\r
package org.apache.poi.ss.usermodel;\r
\r
import junit.framework.TestCase;\r
+import org.apache.poi.ss.ITestDataProvider;\r
\r
/**\r
* Tests row shifting capabilities.\r
* @author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot jp)\r
*/\r
public abstract class BaseTestSheetShiftRows extends TestCase {\r
+\r
/**\r
- * Override to provide HSSF / XSSF specific way for re-serialising a workbook\r
- */\r
- protected abstract Workbook writeOutAndReadBack(Workbook wb);\r
- /**\r
- * Override to provide way of loading HSSF / XSSF sample workbooks\r
- * @param sampleFileName without the ".xls" or ".xlsx" suffix\r
- */\r
- protected abstract Workbook openSampleWorkbook(String sampleFileName);\r
- /**\r
- * Override to provide way of creating HSSF / XSSF workbooks\r
+ * @return an object that provides test data in HSSF / XSSF specific way\r
*/\r
- protected abstract Workbook createWorkbook();\r
+ protected abstract ITestDataProvider getTestDataProvider();\r
\r
/**\r
* Tests the shiftRows function. Does three different shifts.\r
* check. This ensures that if some changes code that breaks\r
* writing or what not, they realize it.\r
*\r
- * @author Shawn Laubach (slaubach at apache dot org)\r
+ * @param sampleName the sample file to test against\r
*/\r
public final void baseTestShiftRows(String sampleName){\r
// Read initial file in\r
- Workbook wb = openSampleWorkbook(sampleName);\r
+ Workbook wb = getTestDataProvider().openSampleWorkbook(sampleName);\r
Sheet s = wb.getSheetAt( 0 );\r
\r
// Shift the second row down 1 and write to temp file\r
s.shiftRows( 1, 1, 1 );\r
\r
- wb = writeOutAndReadBack(wb);\r
+ wb = getTestDataProvider().writeOutAndReadBack(wb);\r
\r
// Read from temp file and check the number of cells in each\r
// row (in original file each row was unique)\r
// Shift rows 1-3 down 3 in the current one. This tests when\r
// 1 row is blank. Write to a another temp file\r
s.shiftRows( 0, 2, 3 );\r
- wb = writeOutAndReadBack(wb);\r
+ wb = getTestDataProvider().writeOutAndReadBack(wb);\r
\r
// Read and ensure things are where they should be\r
s = wb.getSheetAt(0);\r
assertEquals(s.getRow(5).getPhysicalNumberOfCells(), 2);\r
\r
// Read the first file again\r
- wb = openSampleWorkbook(sampleName);\r
+ wb = getTestDataProvider().openSampleWorkbook(sampleName);\r
s = wb.getSheetAt( 0 );\r
\r
// Shift rows 3 and 4 up and write to temp file\r
s.shiftRows( 2, 3, -2 );\r
- wb = writeOutAndReadBack(wb);\r
+ wb = getTestDataProvider().writeOutAndReadBack(wb);\r
s = wb.getSheetAt( 0 );\r
assertEquals(s.getRow(0).getPhysicalNumberOfCells(), 3);\r
assertEquals(s.getRow(1).getPhysicalNumberOfCells(), 4);\r
\r
/**\r
* Tests when rows are null.\r
- *\r
- * @author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot jp)\r
*/\r
public final void baseTestShiftRow() {\r
- Workbook b = createWorkbook();\r
+ Workbook b = getTestDataProvider().createWorkbook();\r
Sheet s = b.createSheet();\r
s.createRow(0).createCell(0).setCellValue("TEST1");\r
s.createRow(3).createCell(0).setCellValue("TEST2");\r
\r
/**\r
* Tests when shifting the first row.\r
- *\r
- * @author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot jp)\r
*/\r
public final void baseTestShiftRow0() {\r
- Workbook b = createWorkbook();\r
+ Workbook b = getTestDataProvider().createWorkbook();\r
Sheet s = b.createSheet();\r
s.createRow(0).createCell(0).setCellValue("TEST1");\r
s.createRow(3).createCell(0).setCellValue("TEST2");\r
*\r
*/\r
public final void baseTestShiftRowBreaks() {\r
- Workbook b = createWorkbook();\r
+ Workbook b = getTestDataProvider().createWorkbook();\r
Sheet s = b.createSheet();\r
Row row = s.createRow(4);\r
row.createCell(0).setCellValue("test");\r
\r
\r
public final void baseTestShiftWithComments(String sampleName) {\r
- Workbook wb = openSampleWorkbook(sampleName);\r
+ Workbook wb = getTestDataProvider().openSampleWorkbook(sampleName);\r
\r
Sheet sheet = wb.getSheet("Sheet1");\r
assertEquals(3, sheet.getLastRowNum());\r
\r
// Write out and read back in again\r
// Ensure that the changes were persisted\r
- wb = writeOutAndReadBack(wb);\r
+ wb = getTestDataProvider().writeOutAndReadBack(wb);\r
sheet = wb.getSheet("Sheet1");\r
assertEquals(4, sheet.getLastRowNum());\r
\r
\r
/**\r
* See bug #34023\r
+ *\r
+ * @param sampleName the sample file to test against\r
*/\r
public void baseTestShiftWithFormulas(String sampleName) {\r
- Workbook wb = openSampleWorkbook(sampleName);\r
+ Workbook wb = getTestDataProvider().openSampleWorkbook(sampleName);\r
\r
Sheet sheet = wb.getSheet("Sheet1");\r
assertEquals(20, sheet.getLastRowNum());\r