spreadsheet icon indicating copy to clipboard operation
spreadsheet copied to clipboard

Spreadsheet.write(OutpuStream out) produces corrupted XLSX files.

Open vaadin-bot opened this issue 9 years ago • 5 comments

Originally by mbranicky


We have a use case when we are loading Excel data from XLSX file right into the Spreadsheet component. Even very large or complex sheets with lot's of styling are loaded correctly. However when we write this data back into the new XLSX file and the excel data contains some formatting (bold font for instance), the outcome file gets corrupted and Excel refuses to open it and offers a repair of such a corrupted file.

To read from excel file:

#!java
this.spreadsheet.read(excelInputResource.getInputStream());

To write into excel file:

#!java
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
this.spreadsheet.write(baos);
String newResourceIcrPath = xlsFilePath + "/" + xlsFileName + "_" + new Date().getTime() + xlsFileSuffix;
// 'excelOutputResource' is our internal resource
IcrResource excelOutputResource = resourceCacheProvider.get().createIcrResource(newResourceIcrPath);
 // writes input stream into the file on file system
excelOutputResource.store(new ByteArrayInputStream(baos.toByteArray()));
IOUtils.closeQuietly(baos); 

I've also tried to use method Spreadsheet.write(String fileName), but the outcome file is still corrupted.

Please see attached original empty file, corrupted file (produced when any formatting is used in excel data) and repaired file. I've also attached an Excel log file, produced by repair process.

VAADIN Core 7.6.8.
VAADIN Spreadsheet 1.2.1
Microsoft Excel for MAC version 15.25

Imported from https://dev.vaadin.com/ issue #20180

vaadin-bot avatar Aug 25 '16 12:08 vaadin-bot

Originally by mbranicky


Attachment added: empty.xlsx (20.5 KiB) Original input file.

vaadin-bot avatar Aug 25 '16 12:08 vaadin-bot

Originally by mbranicky


Attachment added: empty_corrupted.xlsx (13.3 KiB) Created but corrupted outcome file

vaadin-bot avatar Aug 25 '16 12:08 vaadin-bot

Originally by mbranicky


Attachment added: empty_corrupted_and_fixed.xlsx (21.3 KiB) Repaired file

vaadin-bot avatar Aug 25 '16 12:08 vaadin-bot

Originally by mbranicky


Attachment added: repairment_log.xml (0.8 KiB) Rapairment log file

vaadin-bot avatar Aug 25 '16 12:08 vaadin-bot

Originally by @Ansku


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

vaadin-bot avatar Sep 28 '16 16:09 vaadin-bot