-
Bug
-
Resolution: Fixed
-
Major
-
3.0.0 RC
Problem Description
I export a book with images and import to another Spreadsheet 2nd times, it throws
嚴重的: >>org.zkoss.poi.POIXMLException: java.lang.reflect.InvocationTargetException
>>java.lang.reflect.InvocationTargetException: null
>>org.apache.xmlbeans.XmlException: error: Unexpected element: XML_DOC_OR_TEXT_DECL
>>org.xml.sax.SAXParseException: Unexpected element: XML_DOC_OR_TEXT_DECL
>> at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportFatalError(Piccolo.java:1038)
>> at org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:723)
>> at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3439)
>> at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
>> at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
>> at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
>> at org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.WsDrDocument$Factory.parse(Unknown Source)
>> at org.zkoss.poi.xssf.usermodel.XSSFDrawing.<init>(XSSFDrawing.java:92)
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>> at org.zkoss.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
>> at org.zkoss.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:403)
>> at org.zkoss.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:408)
>> at org.zkoss.poi.POIXMLDocument.load(POIXMLDocument.java:155)
>> at org.zkoss.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:271)
>> at org.zkoss.zss.model.sys.impl.XSSFBookImpl.<init>(XSSFBookImpl.java:101)
>> at org.zkoss.zss.model.sys.impl.ExcelImporter.importsFromStream(ExcelImporter.java:117)
>> at org.zkoss.zss.model.sys.impl.ExcelImporter.imports(ExcelImporter.java:78)
>> at org.zkoss.zss.api.impl.ImporterImpl.imports(ImporterImpl.java:21)
>> at zss.testapp.ExportComposer.export2Destination(ExportComposer.java:175)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at org.zkoss.zk.ui.select.Selectors$ComposerEventListener.onEvent(Selectors.java:681)
Reproducing Steps:
- visit zss.test project's export.zul
- or attached source codes (zul, excel file, java), or run zss.test project's ExportTest
- click "input pictures" button
- click "Export to destination Spreadsheet"
- click "Export to destination Spreadsheet" 2nd time
Expected:
No error occurs.
Actual:
the exception described in problem description is thrown.
Notice:
If you use "Insert picture" to insert picture and import the file 2 times, the same exception is also thrown.
public class ExportComposer extends SelectorComposer<Component> { private static final long serialVersionUID = 1L; Exporter excelExporter = Exporters.getExporter("excel"); @Wire("#source") private Spreadsheet srcSpreadsheet; @Wire("#destination") private Spreadsheet dstSpreadsheet; @Listen("onClick = #inputPicture") public void inputChartPicture() throws IOException{ Sheet sheet = srcSpreadsheet.getSelectedSheet(); SheetOperationUtil.addPicture(range(sheet,3, 8 ), new AImage(ExportComposer.class.getResource("zklogo.png")).getByteData(), Format.PNG, 100, 100); } @Listen("onClick = #exportImport") public void export2Destination() throws IOException{ File exportedFile = new File("exported.xlsx"); FileOutputStream fos = new FileOutputStream(exportedFile); excelExporter.export(srcSpreadsheet.getBook(), fos); fos.flush(); fos.close(); //import Importer importer = Importers.getImporter("excel"); Book book = importer .imports(new FileInputStream(exportedFile), "exported"); dstSpreadsheet.setBook(book); exportedFile.delete(); } }
<zk> <window apply="zss.testapp.ExportComposer" height="100%"> <button id="inputPicture" label="Input Pictures and Charts"/> <separator></separator> <button id="exportImport" label="Export to destination Spreadsheet"/> <spreadsheet id="source" src="/export.xlsx" maxrows="150" maxcolumns="40" width="100%" height="50%" showContextMenu="true" showSheetbar="true" showToolbar="true" ctrlKeys="^c^x^v^d^s^o^b^i^u#del^#del^z^y^e" /> <spreadsheet id="destination" maxrows="150" maxcolumns="40" width="100%" height="40%" showContextMenu="true" showSheetbar="true" showToolbar="true" ctrlKeys="^c^x^v^d^s^o^b^i^u#del^#del^z^y^e" /> </window> </zk>
- relates to
-
ZSS-35 A exported xlsx is not loadable again by Excel or Spreadsheet
- Closed