You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2018/12/06 07:52:09 UTC
[Bug 62985] New: Writing to new file saves also changes in source
file
https://bz.apache.org/bugzilla/show_bug.cgi?id=62985
Bug ID: 62985
Summary: Writing to new file saves also changes in source file
Product: POI
Version: 4.0.0-FINAL
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: SS Common
Assignee: dev@poi.apache.org
Reporter: daniela.loew@giz.de
Target Milestone: ---
If I open an existing Excel document, do some changes and save it with a new
file name, the changes are saved in both files. Saving it with the same file
name as the source file leads to the following exception:
Exception in thread "main" org.apache.poi.ooxml.POIXMLException:
java.io.EOFException: Unexpected end of ZLIB input stream
at
org.apache.poi.ooxml.POIXMLDocument.getProperties(POIXMLDocument.java:147)
at org.apache.poi.ooxml.POIXMLDocument.write(POIXMLDocument.java:240)
at de.giz.meb.POIProof.main(POIProof.java:28)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
at
org.apache.commons.compress.archivers.zip.InflaterInputStreamWithStatistics.fill(InflaterInputStreamWithStatistics.java:52)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at
org.apache.commons.compress.archivers.zip.InflaterInputStreamWithStatistics.read(InflaterInputStreamWithStatistics.java:67)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:122)
at
org.apache.commons.compress.archivers.zip.InflaterInputStreamWithStatistics.read(InflaterInputStreamWithStatistics.java:58)
at java.io.FilterInputStream.read(FilterInputStream.java:83)
at
org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.read(ZipArchiveThresholdInputStream.java:69)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(XMLEntityManager.java:2890)
at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:674)
at
com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:148)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:806)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at
org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3414)
at
org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1272)
at
org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1259)
at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
at
org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument$Factory.parse(Unknown
Source)
at
org.apache.poi.ooxml.POIXMLProperties.<init>(POIXMLProperties.java:81)
at
org.apache.poi.ooxml.POIXMLDocument.getProperties(POIXMLDocument.java:145)
... 2 more
You can test it with the following code:
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class POIProof {
public static void main(String[] args) {
Workbook w;
try {
// open existing file
w = WorkbookFactory.create(new
File("C:\\dev\\MyExcel.xlsx"));
Sheet s = w.getSheetAt(0);
Row r = s.getRow(0);
Cell c = r.createCell(1);
c.setCellValue("Easy Test");
// write to new file
FileOutputStream out = new
FileOutputStream("C:\\dev\\MyExcel_mod.xlsx");
w.write(out);
w.close();
} catch (EncryptedDocumentException | IOException e) {
//TODO
}
}
}
We tested that with Version 4.0.0-FINAL and 4.0.1.
Using XSSFWorkbook instead worked fine.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 62985] Writing to new file saves also changes in source file
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62985
Andreas Beeker <ki...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Andreas Beeker <ki...@apache.org> ---
*** This bug has been marked as a duplicate of bug 59287 ***
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org