use of org.apache.poi.openxml4j.opc.OPCPackage in project poi by apache.
the class TestXSSFBSharedStringsTable method testBasic.
@Test
public void testBasic() throws Exception {
OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("51519.xlsb"));
List<PackagePart> parts = pkg.getPartsByName(Pattern.compile("/xl/sharedStrings.bin"));
assertEquals(1, parts.size());
XSSFBSharedStringsTable rtbl = new XSSFBSharedStringsTable(parts.get(0));
List<String> strings = rtbl.getItems();
assertEquals(49, strings.size());
assertEquals("コメント", rtbl.getEntryAt(0));
assertEquals("日本オラクル", rtbl.getEntryAt(3));
assertEquals(55, rtbl.getCount());
assertEquals(49, rtbl.getUniqueCount());
//TODO: add in tests for phonetic runs
}
use of org.apache.poi.openxml4j.opc.OPCPackage in project poi by apache.
the class TestReadOnlySharedStringsTable method testEmptySSTOnPackageObtainedViaWorkbook.
public void testEmptySSTOnPackageObtainedViaWorkbook() throws Exception {
XSSFWorkbook wb = new XSSFWorkbook(_ssTests.openResourceAsStream("noSharedStringTable.xlsx"));
OPCPackage pkg = wb.getPackage();
assertEmptySST(pkg);
wb.close();
}
use of org.apache.poi.openxml4j.opc.OPCPackage in project poi by apache.
the class TestXSSFBReader method getSheets.
private List<String> getSheets(String testFileName) throws Exception {
OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream(testFileName));
List<String> sheetTexts = new ArrayList<String>();
XSSFBReader r = new XSSFBReader(pkg);
// assertNotNull(r.getWorkbookData());
// assertNotNull(r.getSharedStringsData());
assertNotNull(r.getXSSFBStylesTable());
XSSFBSharedStringsTable sst = new XSSFBSharedStringsTable(pkg);
XSSFBStylesTable xssfbStylesTable = r.getXSSFBStylesTable();
XSSFBReader.SheetIterator it = (XSSFBReader.SheetIterator) r.getSheetsData();
while (it.hasNext()) {
InputStream is = it.next();
String name = it.getSheetName();
TestSheetHandler testSheetHandler = new TestSheetHandler();
testSheetHandler.startSheet(name);
XSSFBSheetHandler sheetHandler = new XSSFBSheetHandler(is, xssfbStylesTable, it.getXSSFBSheetComments(), sst, testSheetHandler, new DataFormatter(), false);
sheetHandler.parse();
testSheetHandler.endSheet();
sheetTexts.add(testSheetHandler.toString());
}
return sheetTexts;
}
use of org.apache.poi.openxml4j.opc.OPCPackage in project poi by apache.
the class TestXSSFBReader method testAbsPath.
@Test
public void testAbsPath() throws Exception {
OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("testVarious.xlsb"));
XSSFBReader r = new XSSFBReader(pkg);
assertEquals("C:\\Users\\tallison\\Desktop\\working\\xlsb\\", r.getAbsPathMetadata());
}
use of org.apache.poi.openxml4j.opc.OPCPackage in project poi by apache.
the class TestXSSFReader method testShapes.
/**
* Test text extraction from text box using getShapes()
*
* @throws Exception
*/
public void testShapes() throws Exception {
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("WithTextBox.xlsx");
XSSFReader r = new XSSFReader(pkg);
XSSFReader.SheetIterator it = (XSSFReader.SheetIterator) r.getSheetsData();
String text = getShapesString(it);
assertContains(text, "Line 1");
assertContains(text, "Line 2");
assertContains(text, "Line 3");
}
Aggregations