Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
laohe98 opened this issue Mar 4, 2020 · 1 comment
Closed

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

laohe98 opened this issue Mar 4, 2020 · 1 comment

Comments

@laohe98
Copy link

laohe98 commented Mar 4, 2020

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

@SheetJSDev
Copy link
Contributor

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>";
        }

ChristianUlbrich added a commit to ChristianUlbrich/sheetjs that referenced this issue Mar 10, 2020
RimaCiklum pushed a commit to Folcon/js-xlsx that referenced this issue Aug 20, 2020
- CFB prevent infinite loop (h/t @rossj)
- pass updated eslint checks (fixes SheetJS#1726 h/t @BjoernRave)
- defined name proper encoding (fixes SheetJS#1785 h/t @laohe98)
- correct theme color order (fixes SheetJS#389 h/t @foreverpw)
- ODS / XLML more aggressive flagging of stub cells
- cellStyles implies sheetStubs
- updated SSF to 0.10.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants