import org.apache.poi.util.Removal;
import org.apache.poi.util.TempFile;
import org.apache.poi.xssf.model.SharedStringsTable;
+import org.apache.poi.xssf.usermodel.XSSFChartSheet;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
zos.putNextEntry(new ZipEntry(ze.getName()));
InputStream is = zipEntrySource.getInputStream(ze);
XSSFSheet xSheet=getSheetFromZipEntryName(ze.getName());
- if(xSheet!=null) {
+ // See bug 56557, we should not inject data into the special ChartSheets
+ if(xSheet!=null && !(xSheet instanceof XSSFChartSheet)) {
SXSSFSheet sxSheet=getSXSSFSheet(xSheet);
InputStream xis = sxSheet.getWorksheetXMLInputStream();
try {
assertEquals(true, s.getRow(0).getCell(0).getBooleanCellValue());
assertEquals("Test Row 9", s.getRow(9).getCell(2).getStringCellValue());
}
+
+ @Test
+ public void test56557() throws IOException, InvalidFormatException {
+ Workbook wb = WorkbookFactory.create(XSSFTestDataSamples.getSampleFile("56557.xlsx"));
+
+ // Using streaming XSSFWorkbook makes the output file invalid
+ wb = new SXSSFWorkbook(((XSSFWorkbook) wb));
+
+ Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
+ assertNotNull(wbBack);
+ wbBack.close();
+
+ /*FileOutputStream out = new FileOutputStream("C:/temp/out.xlsx");
+ try {
+ wb.write(out);
+ } finally {
+ out.close();
+ }*/
+
+ wb.close();
+ }
}