XLS BIFF8 export cannot be read by Numbers OSX #1188

Closed
opened 2018-07-19 14:31:08 +00:00 by clicktravel-antonrand · 4 comments
clicktravel-antonrand commented 2018-07-19 14:31:08 +00:00 (Migrated from github.com)

Hello,

I have an XLS file - I read it:

var workbook = XLSX.readFile('./template/amendments.xls');

I don't even modify it - and write it back out:

XLSX.writeFile(workbook, './template/amendments-2.xls');

The resulting file cannot be previewed/opened - if I save it with the .xslx extension it works.

Have you dropped support for the xls format? Documentation suggests it is supported: https://docs.sheetjs.com/#supported-output-formats

I've added the bookType with biff8 but still unviewable. I don't think the file I'm using is relevant.

Thank you

Hello, I have an XLS file - I read it: ``` var workbook = XLSX.readFile('./template/amendments.xls'); ``` I don't even modify it - and write it back out: ``` XLSX.writeFile(workbook, './template/amendments-2.xls'); ``` The resulting file cannot be previewed/opened - if I save it with the `.xslx` extension it works. Have you dropped support for the `xls` format? Documentation suggests it is supported: https://docs.sheetjs.com/#supported-output-formats I've added the bookType with `biff8` but still unviewable. I don't think the file I'm using is relevant. Thank you
SheetJSDev commented 2018-07-19 15:09:57 +00:00 (Migrated from github.com)

Can you share that amendments.xls file? GH doesn't support XLS attachments so please send an email to support [at] sheetjs [dot] com and attach the file

Can you share that `amendments.xls` file? GH doesn't support XLS attachments so please send an email to support [at] sheetjs [dot] com and attach the file
clicktravel-antonrand commented 2018-07-19 15:29:27 +00:00 (Migrated from github.com)

Hello - I've forwarded over. Let me know if you need any more information

Hello - I've forwarded over. Let me know if you need any more information
guojiaqi1027 commented 2018-08-28 07:36:56 +00:00 (Migrated from github.com)

Any updates? I'm facing the same issue on Numbers

Any updates? I'm facing the same issue on Numbers
SheetJSDev commented 2018-08-28 22:05:08 +00:00 (Migrated from github.com)

@clicktravel-antonrand @guojiaqi1027 finally had a moment to dig further, this is a funny issue with a fortunately easy fix. If you'd like to submit this as a PR we'd accept:

+++ b/bits/78_writebiff.js
@@ -191,7 +191,7 @@ function write_ws_biff8(idx/*:number*/, opts, wb/*:Workbook*/) {
        write_biff_rec(ba, "HCenter", writebool(false));
        write_biff_rec(ba, "VCenter", writebool(false));
        /* ... */
-       write_biff_rec(ba, "Dimensions", write_Dimensions(range, opts));
+       write_biff_rec(ba, 0x200, write_Dimensions(range, opts));
        /* ... */
 
        if(b8) ws['!links'] = [];

Explanation: BIFF8 XLS, like other BIFF formats, ultimately stores the data and metadata as a stream of records. There are two officially recognized record types for the Dimensions record (which stores the worksheet dimensions):

For some reason, Numbers only accepts the first type but Excel accepts both. Version 0.12.1 added support for the 0-type Dimensions record, which changed the export record type. The included change forces the 512 record type

@clicktravel-antonrand @guojiaqi1027 finally had a moment to dig further, this is a funny issue with a fortunately easy fix. If you'd like to submit this as a PR we'd accept: ```diff +++ b/bits/78_writebiff.js @@ -191,7 +191,7 @@ function write_ws_biff8(idx/*:number*/, opts, wb/*:Workbook*/) { write_biff_rec(ba, "HCenter", writebool(false)); write_biff_rec(ba, "VCenter", writebool(false)); /* ... */ - write_biff_rec(ba, "Dimensions", write_Dimensions(range, opts)); + write_biff_rec(ba, 0x200, write_Dimensions(range, opts)); /* ... */ if(b8) ws['!links'] = []; ``` Explanation: BIFF8 XLS, like other BIFF formats, ultimately stores the data and metadata as a stream of records. There are two officially recognized record types for the Dimensions record (which stores the worksheet dimensions): - `0x200 = 512` (record enumeration table at https://msdn.microsoft.com/en-us/library/dd945945.aspx) - `0x000 = 0` (used in old Excel versions like Excel 3.0, see page 14 of http://www.idea2ic.com/File_Formats/excel_biff.pdf) For some reason, Numbers only accepts the first type but Excel accepts both. Version 0.12.1 added support for the `0`-type Dimensions record, which changed the export record type. The included change forces the 512 record type
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#1188
No description provided.