Add some unit-tests for setActiveCell(), although bug 61905 reports that Excel still does not read this correctly for HSSF workbooks
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1829518 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
edd87f05b7
commit
8632f0c47e
@ -36,6 +36,7 @@ import java.util.Iterator;
|
|||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
import org.apache.poi.ss.ITestDataProvider;
|
import org.apache.poi.ss.ITestDataProvider;
|
||||||
import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
|
import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
|
||||||
|
import org.apache.poi.ss.util.CellAddress;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.util.NullOutputStream;
|
import org.apache.poi.util.NullOutputStream;
|
||||||
import org.apache.poi.util.TempFile;
|
import org.apache.poi.util.TempFile;
|
||||||
@ -279,8 +280,7 @@ public abstract class BaseTestWorkbook {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removeSheetAt() throws IOException {
|
public void removeSheetAt() throws IOException {
|
||||||
Workbook workbook = _testDataProvider.createWorkbook();
|
try (Workbook workbook = _testDataProvider.createWorkbook()) {
|
||||||
try {
|
|
||||||
workbook.createSheet("sheet1");
|
workbook.createSheet("sheet1");
|
||||||
workbook.createSheet("sheet2");
|
workbook.createSheet("sheet2");
|
||||||
workbook.createSheet("sheet3");
|
workbook.createSheet("sheet3");
|
||||||
@ -324,8 +324,22 @@ public abstract class BaseTestWorkbook {
|
|||||||
|
|
||||||
workbook.removeSheetAt(0);
|
workbook.removeSheetAt(0);
|
||||||
assertEquals(0, workbook.getActiveSheetIndex());
|
assertEquals(0, workbook.getActiveSheetIndex());
|
||||||
} finally {
|
}
|
||||||
workbook.close();
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetActiveCell() throws IOException {
|
||||||
|
try (Workbook wb = _testDataProvider.createWorkbook()) {
|
||||||
|
Sheet sheet = wb.createSheet("new sheet");
|
||||||
|
assertEquals(new CellAddress("A1"), sheet.getActiveCell());
|
||||||
|
sheet.setActiveCell(new CellAddress("E11"));
|
||||||
|
assertEquals(new CellAddress("E11"), sheet.getActiveCell());
|
||||||
|
|
||||||
|
Workbook wbr = _testDataProvider.writeOutAndReadBack(wb);
|
||||||
|
sheet = wbr.getSheet("new sheet");
|
||||||
|
assertEquals(new CellAddress("E11"), sheet.getActiveCell());
|
||||||
|
|
||||||
|
//wbr.write(new FileOutputStream("c:/temp/yyy." + _testDataProvider.getStandardFileNameExtension()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,7 +633,7 @@ public abstract class BaseTestWorkbook {
|
|||||||
wb2.close();
|
wb2.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Workbook newSetSheetNameTestingWorkbook() throws IOException {
|
private Workbook newSetSheetNameTestingWorkbook() {
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
Sheet sh1 = wb.createSheet("Worksheet");
|
Sheet sh1 = wb.createSheet("Worksheet");
|
||||||
Sheet sh2 = wb.createSheet("Testing 47100");
|
Sheet sh2 = wb.createSheet("Testing 47100");
|
||||||
@ -797,11 +811,8 @@ public abstract class BaseTestWorkbook {
|
|||||||
c.setCellStyle(cs);
|
c.setCellStyle(cs);
|
||||||
c.setCellValue("AAA");
|
c.setCellValue("AAA");
|
||||||
}
|
}
|
||||||
OutputStream os = new NullOutputStream();
|
try (OutputStream os = new NullOutputStream()) {
|
||||||
try {
|
|
||||||
workbook.write(os);
|
workbook.write(os);
|
||||||
} finally {
|
|
||||||
os.close();
|
|
||||||
}
|
}
|
||||||
//workbook.dispose();
|
//workbook.dispose();
|
||||||
workbook.close();
|
workbook.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user