Skip to content
  • Rate limit · GitHub

    Access has been restricted

    You have triggered a rate limit.

    Please wait a few minutes before you try again;
    in some cases this may take up to an hour.

  • Notifications You must be signed in to change notification settings
  • Fork 8k

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

Closed
@laohe98

Description

@laohe98

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

Activity

SheetJSDev

SheetJSDev commented on Mar 8, 2020

@SheetJSDev
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>";
        }
added a commit that references this issue on Mar 10, 2020
711ea9c
added a commit that references this issue on Aug 20, 2020
795d5e7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @SheetJSDev@laohe98

      Issue actions

        Read xlsm file and save as new xlsm file, can't be open anymore! · Issue #1785 · SheetJS/sheetjs