Read xlsm file and save as new xlsm file, can't be open anymore! #1785

Closed
opened 2020-03-04 10:22:04 +00:00 by laohe98 · 1 comment
laohe98 commented 2020-03-04 10:22:04 +00:00 (Migrated from github.com)

Dear Team,

There is a xlsm issue block me. Could you help resovle this issue. Thanks a lot.

My code:
image

throw below exception when open the new file:

The file is corrupt and cannot be opened.

Regards
Ivan

CAF.zip

Dear Team, There is a xlsm issue block me. Could you help resovle this issue. Thanks a lot. My code: ![image](https://user-images.githubusercontent.com/27720454/75869464-8e83a280-5e44-11ea-9552-46088b4cc146.png) throw below exception when open the new file: **The file is corrupt and cannot be opened.** Regards Ivan [CAF.zip](https://github.com/SheetJS/sheetjs/files/4286695/CAF.zip)
SheetJSDev commented 2020-03-08 06:01:51 +00:00 (Migrated from github.com)

For the general problem of editing a template file, in our Pro compendium we have a special template editor build that elegantly handles complex templates.

In this specific case, the corrupt error stems from a defined name with an ampersand. We fixed this a while ago in our Pro builds but it hasn't been updated in our open source yet. Feel free to submit the following patch:

diff --git a/bits/72_wbxml.js b/bits/72_wbxml.js
index cb9dff2..0189b32 100644
--- a/bits/72_wbxml.js
+++ b/bits/72_wbxml.js
@@ -218,7 +218,7 @@ function write_wb_xml(wb/*:Workbook*//*::, opts:?WriteOpts*/)/*:string*/ {
                        if(n.Sheet != null) d.localSheetId = ""+n.Sheet;
                        if(n.Hidden) d.hidden = "1";
                        if(!n.Ref) return;
-                       o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "&lt;").replace(/>/g, "&gt;"), d);
+                       o[o.length] = writextag('definedName', escapexml(n.Ref), d);
                });
                o[o.length] = "</definedNames>";
        }
For the general problem of editing a template file, in our Pro compendium we have a special template editor build that elegantly handles complex templates. In this specific case, the corrupt error stems from a defined name with an ampersand. We fixed this a while ago in our Pro builds but it hasn't been updated in our open source yet. Feel free to submit the following patch: ```diff diff --git a/bits/72_wbxml.js b/bits/72_wbxml.js index cb9dff2..0189b32 100644 --- a/bits/72_wbxml.js +++ b/bits/72_wbxml.js @@ -218,7 +218,7 @@ function write_wb_xml(wb/*:Workbook*//*::, opts:?WriteOpts*/)/*:string*/ { if(n.Sheet != null) d.localSheetId = ""+n.Sheet; if(n.Hidden) d.hidden = "1"; if(!n.Ref) return; - o[o.length] = writextag('definedName', String(n.Ref).replace(/</g, "&lt;").replace(/>/g, "&gt;"), d); + o[o.length] = writextag('definedName', escapexml(n.Ref), d); }); o[o.length] = "</definedNames>"; } ```
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#1785
No description provided.