use of org.apache.poi.hssf.usermodel.HSSFWorkbook in project poi by apache.
the class HSSFFileHandler method handleFile.
@Override
public void handleFile(InputStream stream, String path) throws Exception {
HSSFWorkbook wb = new HSSFWorkbook(stream);
handleWorkbook(wb);
// TODO: some documents fail currently...
// Note - as of Bugzilla 48036 (svn r828244, r828247) POI is capable of evaluating
// IntersectionPtg. However it is still not capable of parsing it.
// So FormulaEvalTestData.xls now contains a few formulas that produce errors here.
//HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
//evaluator.evaluateAll();
delegate.handlePOIDocument(wb);
// also try to see if some of the Records behave incorrectly
// TODO: still fails on some records... RecordsStresser.handleWorkbook(wb);
}
use of org.apache.poi.hssf.usermodel.HSSFWorkbook in project poi by apache.
the class TestDrawingAggregate method testSerializeDrawingBigger8k_noAggregation.
@Test
public void testSerializeDrawingBigger8k_noAggregation() throws IOException {
HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("DrawingContinue.xls");
InternalSheet isheet = HSSFTestHelper.getSheetForTest(wb1.getSheetAt(0));
List<RecordBase> records = isheet.getRecords();
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
wb1.close();
InternalSheet isheet2 = HSSFTestHelper.getSheetForTest(wb2.getSheetAt(0));
List<RecordBase> records2 = isheet2.getRecords();
assertEquals(records.size(), records2.size());
for (int i = 0; i < records.size(); i++) {
RecordBase r1 = records.get(i);
RecordBase r2 = records2.get(i);
assertTrue(r1.getClass() == r2.getClass());
assertEquals(r1.getRecordSize(), r2.getRecordSize());
if (r1 instanceof Record) {
assertEquals(((Record) r1).getSid(), ((Record) r2).getSid());
assertArrayEquals(((Record) r1).serialize(), ((Record) r2).serialize());
}
}
wb2.close();
}
use of org.apache.poi.hssf.usermodel.HSSFWorkbook in project poi by apache.
the class TestDrawingAggregate method testFailing.
/**
* TODO: figure out why it fails with "RecordFormatException: 0 bytes written but getRecordSize() reports 80"
*/
@Test
public void testFailing() throws IOException {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("15573.xls");
HSSFSheet sh = wb.getSheetAt(0);
sh.getDrawingPatriarch();
HSSFTestDataSamples.writeOutAndReadBack(wb).close();
wb.close();
}
use of org.apache.poi.hssf.usermodel.HSSFWorkbook in project poi by apache.
the class TestDrawingShapes method testShapeContainerImplementsIterable.
@SuppressWarnings("unused")
@Test
public void testShapeContainerImplementsIterable() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
patriarch.createSimpleShape(new HSSFClientAnchor());
patriarch.createSimpleShape(new HSSFClientAnchor());
int i = 2;
for (HSSFShape shape : patriarch) {
i--;
}
assertEquals(i, 0);
wb.close();
}
use of org.apache.poi.hssf.usermodel.HSSFWorkbook in project poi by apache.
the class TestHPSFPropertiesExtractor method testConstructors.
public void testConstructors() throws IOException {
POIFSFileSystem fs;
HSSFWorkbook wb;
try {
fs = new POIFSFileSystem(_samples.openResourceAsStream("TestUnicode.xls"));
wb = new HSSFWorkbook(fs);
} catch (IOException e) {
throw new RuntimeException(e);
}
ExcelExtractor excelExt = new ExcelExtractor(wb);
final String fsText;
HPSFPropertiesExtractor fsExt = new HPSFPropertiesExtractor(fs);
// Don't close re-used test resources!
fsExt.setFilesystem(null);
try {
fsText = fsExt.getText();
} finally {
fsExt.close();
}
final String hwText;
HPSFPropertiesExtractor hwExt = new HPSFPropertiesExtractor(wb);
// Don't close re-used test resources!
hwExt.setFilesystem(null);
try {
hwText = hwExt.getText();
} finally {
hwExt.close();
}
final String eeText;
HPSFPropertiesExtractor eeExt = new HPSFPropertiesExtractor(excelExt);
// Don't close re-used test resources!
eeExt.setFilesystem(null);
try {
eeText = eeExt.getText();
} finally {
eeExt.close();
wb.close();
}
assertEquals(fsText, hwText);
assertEquals(fsText, eeText);
assertContains(fsText, "AUTHOR = marshall");
assertContains(fsText, "TITLE = Titel: Äh");
}
Aggregations