added setDisplayZeros / isDisplayZeros and getMergedRegion(int) to common interface org.apache.poi.ss.usermodel.Sheet; more progress on testing common xssf-hssf interfaces
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@747307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e5f18378bd
commit
4862f72197
@ -36,14 +36,16 @@
|
||||
</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>
|
||||
|
@ -33,14 +33,16 @@
|
||||
|
||||
<!-- 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>
|
||||
|
@ -841,6 +841,31 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
||||
.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
|
||||
|
@ -238,6 +238,13 @@ public interface Sheet extends Iterable<Row> {
|
||||
*/
|
||||
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
|
||||
*
|
||||
@ -260,6 +267,23 @@ public interface Sheet extends Iterable<Row> {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -539,6 +539,28 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
||||
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
|
||||
*
|
||||
|
49
src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
Executable file
49
src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
Executable file
@ -0,0 +1,49 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.xssf;
|
||||
|
||||
import org.apache.poi.ss.ITestDataProvider;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class XSSFITestDataProvider implements ITestDataProvider {
|
||||
|
||||
public XSSFWorkbook openSampleWorkbook(String sampleFileName) {
|
||||
return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
|
||||
}
|
||||
|
||||
public XSSFWorkbook writeOutAndReadBack(Workbook original) {
|
||||
if(!(original instanceof XSSFWorkbook)) {
|
||||
throw new IllegalArgumentException("Expected an instance of XSSFWorkbook");
|
||||
}
|
||||
|
||||
return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original);
|
||||
}
|
||||
|
||||
public XSSFWorkbook createWorkbook(){
|
||||
return new XSSFWorkbook();
|
||||
}
|
||||
|
||||
private XSSFITestDataProvider(){}
|
||||
private static XSSFITestDataProvider inst = new XSSFITestDataProvider();
|
||||
public static XSSFITestDataProvider getInstance(){
|
||||
return inst;
|
||||
}
|
||||
}
|
@ -17,8 +17,8 @@
|
||||
package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
import org.apache.poi.ss.ITestDataProvider;
|
||||
import org.apache.poi.xssf.XSSFITestDataProvider;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
@ -26,18 +26,8 @@ import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
public class TestSheetShiftRows extends BaseTestSheetShiftRows {
|
||||
|
||||
@Override
|
||||
protected Workbook openSampleWorkbook(String sampleFileName) {
|
||||
return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Workbook writeOutAndReadBack(Workbook wb) {
|
||||
return XSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Workbook createWorkbook() {
|
||||
return new XSSFWorkbook();
|
||||
protected ITestDataProvider getTestDataProvider(){
|
||||
return XSSFITestDataProvider.getInstance();
|
||||
}
|
||||
|
||||
public void testShiftRows() {
|
||||
|
@ -926,4 +926,32 @@ public class TestXSSFSheet extends TestCase {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
50
src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java
Executable file
50
src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java
Executable file
@ -0,0 +1,50 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.hssf;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.ITestDataProvider;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class HSSFITestDataProvider implements ITestDataProvider {
|
||||
|
||||
public HSSFWorkbook openSampleWorkbook(String sampleFileName) {
|
||||
return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);
|
||||
}
|
||||
|
||||
public HSSFWorkbook writeOutAndReadBack(Workbook original) {
|
||||
if(!(original instanceof HSSFWorkbook)) {
|
||||
throw new IllegalArgumentException("Expected an instance of HSSFWorkbook");
|
||||
}
|
||||
|
||||
return HSSFTestDataSamples.writeOutAndReadBack((HSSFWorkbook)original);
|
||||
}
|
||||
|
||||
public HSSFWorkbook createWorkbook(){
|
||||
return new HSSFWorkbook();
|
||||
}
|
||||
|
||||
private HSSFITestDataProvider(){}
|
||||
private static HSSFITestDataProvider inst = new HSSFITestDataProvider();
|
||||
public static HSSFITestDataProvider getInstance(){
|
||||
return inst;
|
||||
}
|
||||
}
|
@ -538,16 +538,15 @@ public final class TestHSSFSheet extends TestCase {
|
||||
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);
|
||||
@ -555,6 +554,7 @@ public final class TestHSSFSheet extends TestCase {
|
||||
assertEquals(sheet.isDisplayGridlines(), false);
|
||||
assertEquals(sheet.isDisplayRowColHeadings(), false);
|
||||
assertEquals(sheet.isDisplayFormulas(), true);
|
||||
assertEquals(sheet.isDisplayZeros(), false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,8 +17,7 @@
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
@ -30,23 +29,11 @@ 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");
|
||||
|
47
src/testcases/org/apache/poi/ss/ITestDataProvider.java
Executable file
47
src/testcases/org/apache/poi/ss/ITestDataProvider.java
Executable file
@ -0,0 +1,47 @@
|
||||
/* ====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
package org.apache.poi.ss;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
/**
|
||||
* Incapsulates a provider of test data for common HSSF / XSSF tests.
|
||||
*/
|
||||
public interface ITestDataProvider {
|
||||
/**
|
||||
* Override to provide HSSF / XSSF specific way for re-serialising a workbook
|
||||
*
|
||||
* @param wb the workbook to re-serialize
|
||||
* @return the re-serialized workbook
|
||||
*/
|
||||
Workbook writeOutAndReadBack(Workbook wb);
|
||||
|
||||
/**
|
||||
* Override to provide way of loading HSSF / XSSF sample workbooks
|
||||
*
|
||||
* @param sampleFileName the file name to load
|
||||
* @return an instance of Workbook loaded from the supplied file name
|
||||
*/
|
||||
Workbook openSampleWorkbook(String sampleFileName);
|
||||
|
||||
/**
|
||||
* Override to provide way of creating HSSF / XSSF workbooks
|
||||
* @return an instance of Workbook
|
||||
*/
|
||||
Workbook createWorkbook();
|
||||
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
package org.apache.poi.ss.usermodel;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.poi.ss.ITestDataProvider;
|
||||
|
||||
/**
|
||||
* Tests row shifting capabilities.
|
||||
@ -26,19 +27,11 @@ import junit.framework.TestCase;
|
||||
* @author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot jp)
|
||||
*/
|
||||
public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
|
||||
/**
|
||||
* Override to provide HSSF / XSSF specific way for re-serialising a workbook
|
||||
* @return an object that provides test data in HSSF / XSSF specific way
|
||||
*/
|
||||
protected abstract Workbook writeOutAndReadBack(Workbook wb);
|
||||
/**
|
||||
* Override to provide way of loading HSSF / XSSF sample workbooks
|
||||
* @param sampleFileName without the ".xls" or ".xlsx" suffix
|
||||
*/
|
||||
protected abstract Workbook openSampleWorkbook(String sampleFileName);
|
||||
/**
|
||||
* Override to provide way of creating HSSF / XSSF workbooks
|
||||
*/
|
||||
protected abstract Workbook createWorkbook();
|
||||
protected abstract ITestDataProvider getTestDataProvider();
|
||||
|
||||
/**
|
||||
* Tests the shiftRows function. Does three different shifts.
|
||||
@ -46,17 +39,17 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
* check. This ensures that if some changes code that breaks
|
||||
* writing or what not, they realize it.
|
||||
*
|
||||
* @author Shawn Laubach (slaubach at apache dot org)
|
||||
* @param sampleName the sample file to test against
|
||||
*/
|
||||
public final void baseTestShiftRows(String sampleName){
|
||||
// Read initial file in
|
||||
Workbook wb = openSampleWorkbook(sampleName);
|
||||
Workbook wb = getTestDataProvider().openSampleWorkbook(sampleName);
|
||||
Sheet s = wb.getSheetAt( 0 );
|
||||
|
||||
// Shift the second row down 1 and write to temp file
|
||||
s.shiftRows( 1, 1, 1 );
|
||||
|
||||
wb = writeOutAndReadBack(wb);
|
||||
wb = getTestDataProvider().writeOutAndReadBack(wb);
|
||||
|
||||
// Read from temp file and check the number of cells in each
|
||||
// row (in original file each row was unique)
|
||||
@ -71,7 +64,7 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
// Shift rows 1-3 down 3 in the current one. This tests when
|
||||
// 1 row is blank. Write to a another temp file
|
||||
s.shiftRows( 0, 2, 3 );
|
||||
wb = writeOutAndReadBack(wb);
|
||||
wb = getTestDataProvider().writeOutAndReadBack(wb);
|
||||
|
||||
// Read and ensure things are where they should be
|
||||
s = wb.getSheetAt(0);
|
||||
@ -83,12 +76,12 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
assertEquals(s.getRow(5).getPhysicalNumberOfCells(), 2);
|
||||
|
||||
// Read the first file again
|
||||
wb = openSampleWorkbook(sampleName);
|
||||
wb = getTestDataProvider().openSampleWorkbook(sampleName);
|
||||
s = wb.getSheetAt( 0 );
|
||||
|
||||
// Shift rows 3 and 4 up and write to temp file
|
||||
s.shiftRows( 2, 3, -2 );
|
||||
wb = writeOutAndReadBack(wb);
|
||||
wb = getTestDataProvider().writeOutAndReadBack(wb);
|
||||
s = wb.getSheetAt( 0 );
|
||||
assertEquals(s.getRow(0).getPhysicalNumberOfCells(), 3);
|
||||
assertEquals(s.getRow(1).getPhysicalNumberOfCells(), 4);
|
||||
@ -103,11 +96,9 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
|
||||
/**
|
||||
* Tests when rows are null.
|
||||
*
|
||||
* @author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot jp)
|
||||
*/
|
||||
public final void baseTestShiftRow() {
|
||||
Workbook b = createWorkbook();
|
||||
Workbook b = getTestDataProvider().createWorkbook();
|
||||
Sheet s = b.createSheet();
|
||||
s.createRow(0).createCell(0).setCellValue("TEST1");
|
||||
s.createRow(3).createCell(0).setCellValue("TEST2");
|
||||
@ -116,11 +107,9 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
|
||||
/**
|
||||
* Tests when shifting the first row.
|
||||
*
|
||||
* @author Toshiaki Kamoshida (kamoshida.toshiaki at future dot co dot jp)
|
||||
*/
|
||||
public final void baseTestShiftRow0() {
|
||||
Workbook b = createWorkbook();
|
||||
Workbook b = getTestDataProvider().createWorkbook();
|
||||
Sheet s = b.createSheet();
|
||||
s.createRow(0).createCell(0).setCellValue("TEST1");
|
||||
s.createRow(3).createCell(0).setCellValue("TEST2");
|
||||
@ -132,7 +121,7 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
*
|
||||
*/
|
||||
public final void baseTestShiftRowBreaks() {
|
||||
Workbook b = createWorkbook();
|
||||
Workbook b = getTestDataProvider().createWorkbook();
|
||||
Sheet s = b.createSheet();
|
||||
Row row = s.createRow(4);
|
||||
row.createCell(0).setCellValue("test");
|
||||
@ -144,7 +133,7 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
|
||||
|
||||
public final void baseTestShiftWithComments(String sampleName) {
|
||||
Workbook wb = openSampleWorkbook(sampleName);
|
||||
Workbook wb = getTestDataProvider().openSampleWorkbook(sampleName);
|
||||
|
||||
Sheet sheet = wb.getSheet("Sheet1");
|
||||
assertEquals(3, sheet.getLastRowNum());
|
||||
@ -182,7 +171,7 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
|
||||
// Write out and read back in again
|
||||
// Ensure that the changes were persisted
|
||||
wb = writeOutAndReadBack(wb);
|
||||
wb = getTestDataProvider().writeOutAndReadBack(wb);
|
||||
sheet = wb.getSheet("Sheet1");
|
||||
assertEquals(4, sheet.getLastRowNum());
|
||||
|
||||
@ -203,9 +192,11 @@ public abstract class BaseTestSheetShiftRows extends TestCase {
|
||||
|
||||
/**
|
||||
* See bug #34023
|
||||
*
|
||||
* @param sampleName the sample file to test against
|
||||
*/
|
||||
public void baseTestShiftWithFormulas(String sampleName) {
|
||||
Workbook wb = openSampleWorkbook(sampleName);
|
||||
Workbook wb = getTestDataProvider().openSampleWorkbook(sampleName);
|
||||
|
||||
Sheet sheet = wb.getSheet("Sheet1");
|
||||
assertEquals(20, sheet.getLastRowNum());
|
||||
|
Loading…
Reference in New Issue
Block a user