every xls and xlsx file when saved as .ods get corrupted. #649

Closed
opened 2017-05-09 18:29:26 +00:00 by WaqasJaved1 · 9 comments
WaqasJaved1 commented 2017-05-09 18:29:26 +00:00 (Migrated from github.com)
No description provided.
SheetJSDev commented 2017-05-09 18:49:49 +00:00 (Migrated from github.com)

Can you share the original file, the code that you used to convert, and the resulting ODS file?

I just checked using the sheetjs.xlsx file generated by the write test:

  • LibreOffice opens the file without warning
  • Excel 2013 for Windows warns but can repair the file
  • Excel 2016 for Mac warns but can repair the file

GH doesn't support the ODS extension, so remove the .zip extension to see:

sheetjs.ods.zip -- the ODS file generated in the test (so this is "from scratch")

sheetjs.xlsx.ods.zip -- the ODS file generated by the command xlsx -Y sheetjs.xlsx (so this is reading an XLSX file and converting to ODS)

Can you share the original file, the code that you used to convert, and the resulting ODS file? I just checked using the [sheetjs.xlsx](https://github.com/SheetJS/js-xlsx/files/987690/sheetjs.xlsx) file generated by the [write test](https://github.com/SheetJS/js-xlsx/blob/master/tests/write.js): - LibreOffice opens the file without warning - Excel 2013 for Windows warns but can repair the file - Excel 2016 for Mac warns but can repair the file GH doesn't support the ODS extension, so remove the `.zip` extension to see: [sheetjs.ods.zip](https://github.com/SheetJS/js-xlsx/files/987698/sheetjs.ods.zip) -- the ODS file generated in the test (so this is "from scratch") [sheetjs.xlsx.ods.zip](https://github.com/SheetJS/js-xlsx/files/987699/sheetjs.xlsx.ods.zip) -- the ODS file generated by the command `xlsx -Y sheetjs.xlsx` (so this is reading an XLSX file and converting to ODS)
WaqasJaved1 commented 2017-05-10 07:00:58 +00:00 (Migrated from github.com)

I am using it in node.js

var xlsx = require('xlsx'); var workbook = xlsx.readFile('sample.xlsx'); xlsx.writeFile(workbook, 'out.ods');

In office the file get opened after repairing it. But i want it to be displayed in browser using viewerjs http://viewerjs.org/

When i convert sample.xlsx using Microsoft Office it get show no warning in MS and also opens up in browser but when i convert sample.xlsx using this library it show error in MS and also do'nt show up in viewerjs

My basic aim is to convert xlsx to ods and then display it in browser.

I am using it in node.js `var xlsx = require('xlsx'); var workbook = xlsx.readFile('sample.xlsx'); xlsx.writeFile(workbook, 'out.ods');` In office the file get opened after repairing it. But i want it to be displayed in browser using viewerjs http://viewerjs.org/ When i convert sample.xlsx using Microsoft Office it get show no warning in MS and also opens up in browser but when i convert sample.xlsx using this library it show error in MS and also do'nt show up in viewerjs My basic aim is to convert xlsx to ods and then display it in browser.
SheetJSDev commented 2017-05-10 15:40:59 +00:00 (Migrated from github.com)

LibreOffice opens the files without warning, which suggests the generated files are valid. Ask the viewerjs.org people about why they can't display the files.

As for Excel, based on the error messages it looks like Excel requires certain fields that are technically optional according to the OpenDocument specifications. The Windows versions won't show you any error messages, but the Mac versions of Excel generate conversion logs with messages like:

  <removedParts summary="Following is a list of removed parts:">
    <removedPart>Removed Part: /xl/styles.xml with XML error.  (Styles) System error: -2147418113. Line 2, column 1014.</removedPart>
  </removedParts>
  <repairedRecords summary="Following is a list of repairs:">
    <repairedRecord>Repaired Records: Column information from /xl/worksheets/sheet1.xml</repairedRecord>
  </repairedRecords>

On a lark, we tried pulling the missing parts (styles as well as metadata) from an Excel 2013 ODS file and Excel 2013/2016 read the file without warning. Here's a sample (rename the .zip to .ods):

sheetjs.zip

This will be added to the next version

LibreOffice opens the files without warning, which suggests the generated files are valid. Ask the viewerjs.org people about why they can't display the files. As for Excel, based on the error messages it looks like Excel requires certain fields that are technically optional according to the OpenDocument specifications. The Windows versions won't show you any error messages, but the Mac versions of Excel generate conversion logs with messages like: ```xml <removedParts summary="Following is a list of removed parts:"> <removedPart>Removed Part: /xl/styles.xml with XML error. (Styles) System error: -2147418113. Line 2, column 1014.</removedPart> </removedParts> <repairedRecords summary="Following is a list of repairs:"> <repairedRecord>Repaired Records: Column information from /xl/worksheets/sheet1.xml</repairedRecord> </repairedRecords> ``` On a lark, we tried pulling the missing parts (styles as well as metadata) from an Excel 2013 ODS file and Excel 2013/2016 read the file without warning. Here's a sample (rename the .zip to .ods): [sheetjs.zip](https://github.com/SheetJS/js-xlsx/files/990318/sheetjs.zip) This will be added to the next version
WaqasJaved1 commented 2017-05-10 18:37:50 +00:00 (Migrated from github.com)

Thanks Can you tell when will this be pushed to git?

Thanks Can you tell when will this be pushed to git?
SheetJSDev commented 2017-05-11 07:40:40 +00:00 (Migrated from github.com)

@WaqasJaved1 we just pushed to the repo. Based on our tests, Excel will fail on ODS files without styles.xml, so we now add a stub. As Excel and LibreOffice both open the files, we can assert that any issues with third-party readers reflect bugs with those tools rather than corruption in the generation process.

@WaqasJaved1 we just pushed to the repo. Based on our tests, Excel will fail on ODS files without styles.xml, so we now add a stub. As Excel and LibreOffice both open the files, we can assert that any issues with third-party readers reflect bugs with those tools rather than corruption in the generation process.
WaqasJaved1 commented 2017-05-11 17:32:26 +00:00 (Migrated from github.com)

@SheetJSDev Thanks for quick response. I have tried updated new version. The converted file you sent me open successfully in viewer and also in MS. But when i convert my files from this library it is still showing error on MS 2016 and also not opening in viewer.

I am using following code to convert
var xlsx=require('xlsx'); var workbook = xlsx.readFile('sample.xlsx'); xlsx.writeFile(workbook, 'out.ods');

sample.xlsx
out.ods.zip

@SheetJSDev Thanks for quick response. I have tried updated new version. The converted file you sent me open successfully in viewer and also in MS. But when i convert my files from this library it is still showing error on MS 2016 and also not opening in viewer. I am using following code to convert `var xlsx=require('xlsx'); var workbook = xlsx.readFile('sample.xlsx'); xlsx.writeFile(workbook, 'out.ods');` [sample.xlsx](https://github.com/SheetJS/js-xlsx/files/993910/sample.xlsx) [out.ods.zip](https://github.com/SheetJS/js-xlsx/files/993912/out.ods.zip)
SheetJSDev commented 2017-05-11 17:44:44 +00:00 (Migrated from github.com)

@WaqasJaved1 We updated the git repo but have not bumped the version or published to NPM. Give us about an hour to make sure all of the tests pass, then we'll push 0.10.1.

@WaqasJaved1 We updated the git repo but have not bumped the version or published to NPM. Give us about an hour to make sure all of the tests pass, then we'll push 0.10.1.
SheetJSDev commented 2017-05-11 19:06:08 +00:00 (Migrated from github.com)

@WaqasJaved1 we just pushed 0.10.1 to npm, update your local version with npm install xlsx and try again.

@WaqasJaved1 we just pushed 0.10.1 to npm, update your local version with `npm install xlsx` and try again.
WaqasJaved1 commented 2017-05-11 19:21:51 +00:00 (Migrated from github.com)

@SheetJSDev very professional work.
I have tried and it works fine now.
There is no text decoration in converted file. In future are you guys planning to do that part?

@SheetJSDev very professional work. I have tried and it works fine now. There is no text decoration in converted file. In future are you guys planning to do that part?
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#649
No description provided.