Expand on XSSFWorkbook tests, and get them working (needs updated ooxml)
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@639752 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a769181ff3
commit
695dc4812e
@ -29,6 +29,10 @@ import org.apache.poi.xssf.model.StylesTable;
|
|||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
|
||||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
|
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
|
||||||
|
|
||||||
|
import org.openxml4j.opc.ContentTypes;
|
||||||
|
import org.openxml4j.opc.Package;
|
||||||
|
import org.openxml4j.opc.PackagePart;
|
||||||
|
import org.openxml4j.opc.PackagingURIHelper;
|
||||||
|
|
||||||
public class TestXSSFWorkbook extends TestCase {
|
public class TestXSSFWorkbook extends TestCase {
|
||||||
public TestXSSFWorkbook(String name) {
|
public TestXSSFWorkbook(String name) {
|
||||||
@ -170,8 +174,22 @@ public class TestXSSFWorkbook extends TestCase {
|
|||||||
workbook.write(out);
|
workbook.write(out);
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
// Load back in again
|
// Check the package contains what we'd expect it to
|
||||||
workbook = new XSSFWorkbook(file.toString());
|
Package pkg = Package.open(file.toString());
|
||||||
|
PackagePart wbRelPart =
|
||||||
|
pkg.getPart(PackagingURIHelper.createPartName("/xl/_rels/workbook.xml.rels"));
|
||||||
|
assertNotNull(wbRelPart);
|
||||||
|
assertTrue(wbRelPart.isRelationshipPart());
|
||||||
|
assertEquals(ContentTypes.RELATIONSHIPS_PART, wbRelPart.getContentType());
|
||||||
|
|
||||||
|
PackagePart wbPart =
|
||||||
|
pkg.getPart(PackagingURIHelper.createPartName("/xl/workbook.xml"));
|
||||||
|
// Links to the three sheets
|
||||||
|
assertTrue(wbPart.hasRelationships());
|
||||||
|
assertEquals(3, wbPart.getRelationships().size());
|
||||||
|
|
||||||
|
// Load back the XSSFWorkbook
|
||||||
|
workbook = new XSSFWorkbook(pkg);
|
||||||
assertEquals(3, workbook.getNumberOfSheets());
|
assertEquals(3, workbook.getNumberOfSheets());
|
||||||
assertNotNull(workbook.getSheetAt(0));
|
assertNotNull(workbook.getSheetAt(0));
|
||||||
assertNotNull(workbook.getSheetAt(1));
|
assertNotNull(workbook.getSheetAt(1));
|
||||||
@ -195,6 +213,16 @@ public class TestXSSFWorkbook extends TestCase {
|
|||||||
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
|
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
|
||||||
assertNotNull(workbook.getSharedStringSource());
|
assertNotNull(workbook.getSharedStringSource());
|
||||||
assertNotNull(workbook.getStylesSource());
|
assertNotNull(workbook.getStylesSource());
|
||||||
|
|
||||||
|
// And check a few low level bits too
|
||||||
|
Package pkg = Package.open(xml.toString());
|
||||||
|
PackagePart wbPart =
|
||||||
|
pkg.getPart(PackagingURIHelper.createPartName("/xl/workbook.xml"));
|
||||||
|
|
||||||
|
// Links to the three sheets, shared, styles and themes
|
||||||
|
assertTrue(wbPart.hasRelationships());
|
||||||
|
assertEquals(6, wbPart.getRelationships().size());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLoadSave() throws Exception {
|
public void testLoadSave() throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user