https://bz.apache.org/bugzilla/show_bug.cgi?id=60977

            Bug ID: 60977
           Summary: Adding Properties create invalid .xlsx file
           Product: POI
           Version: 3.15-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: ther...@cyberrock.net
  Target Milestone: ---

Created attachment 34909
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34909&action=edit
Example created file

When adding a custom property, and invalid .xlsx is created.

using the java code:

try (final XSSFWorkbookworkbook = new XSSFWorkbook()) {
   final POIXMLProperties properties = workbook.getProperties();
   final POIXMLProperties.CustomProperties customProperties =
properties.getCustomProperties();
   customProperties.addProperty("Project", project.getName());

   workbook.write(outputStream);

   try (final java.io.FileOutputStream fs = new
java.io.FileOutputStream("C:\\temp\\temp.xlsx")) {
      workbook.write(fs);
   }


 When you try to open temp.xlsx in Excel, you get a "file is corrupted"
warning.

 Upon disassembling the .xlsx file, I found the following incorrect custom.xml
file in docProps:

 <?xml version="1.0" encoding="UTF-8"?>
<Properties
xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties";
xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes";><property
pid="2" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"
name="Project"><vt:lpwstr>test</vt:lpwstr></property></Properties><?xml
version="1.0" encoding="UTF-8"?>
<Properties
xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties";
xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes";><property
pid="2" fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"
name="Project"><vt:lpwstr>test</vt:lpwstr></property></Properties>

Note the file seems to be written twice.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to