Skip to content

Unknown Namespace:  #2075

Closed
Closed

Description

@Beful

Uncaught Error: Unknown Namespace:
at Xlsx.js:21598
at of (Xlsx.js:21600)
at hf (Xlsx.js:21973)
at Object.pf [as read] (Xlsx.js:22087)
at XMLHttpRequest.r.onload (Xlsx.js:1828)

image
image

Activity

  1. SheetJSDev commented on Aug 1, 2020

    @SheetJSDev
    Contributor

    Can you share a sample file? The check is https://github.com/SheetJS/sheetjs/blob/master/bits/30_ctype.js#L220 which may not even be necessary if Excel doesn't require the namespace for [Content_Types].xml

  2. Beful commented on Aug 3, 2020

    @Beful
    Author
    var nContainer = document.getElementById('container')
    var xlsx = new Plus.Xlsx(nContainer)
    xlsx.readFile("/200.xlsx");
  3. SheetJSDev commented on Aug 3, 2020

    @SheetJSDev
    Contributor

    Can you share that 200.xlsx file?

  4. Beful commented on Aug 3, 2020

    @Beful
    Author

    可以

  5. Beful commented on Aug 3, 2020

    @Beful
    Author

    image

    又报这个错

  6. Beful commented on Aug 3, 2020

    @Beful
    Author
  7. SheetJSDev commented on Aug 3, 2020

    @SheetJSDev
    Contributor

    谢谢!

    Feel free to submit a patch. The change is in bits/22_xmlutils.js:

    --- a/bits/22_xmlutils.js
    +++ b/bits/22_xmlutils.js
    @@ -1,6 +1,6 @@
     var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
     var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
    -var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g;
    +var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg;
     
     if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
     var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;

    This is a problem with how we are parsing XML tags. There is a CRLF newline sequence within the root tag, just before the closing >:

    00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231  <?xml version="1
    00000010: 2e30 2220 656e 636f 6469 6e67 3d22 5554  .0" encoding="UT
    00000020: 462d 3822 2073 7461 6e64 616c 6f6e 653d  F-8" standalone=
    00000030: 2279 6573 223f 3e0d 3c54 7970 6573 2078  "yes"?>.<Types x
    00000040: 6d6c 6e73 3d22 6874 7470 3a2f 2f73 6368  mlns="http://sch
    00000050: 656d 6173 2e6f 7065 6e78 6d6c 666f 726d  emas.openxmlform
    00000060: 6174 732e 6f72 672f 7061 636b 6167 652f  ats.org/package/
    00000070: 3230 3036 2f63 6f6e 7465 6e74 2d74 7970  2006/content-typ
    00000080: 6573 2220 0d0a 3e0d 3c44 6566 6175 6c74  es" ..>.<Default
                        ::::
    

    The proposed fix changes the RegExp to use the /m flag and changes the penultimate check to match any number of whitespace characters.

  8. Beful commented on Aug 3, 2020

    @Beful
    Author

    image

    I,m read 虚拟目录 ,请求链接,是不是不支持

  9. added a commit that references this issue on Aug 20, 2020
    28212d4
  10. keithpan commented on Dec 15, 2020

    @keithpan

    @SheetJSDev
    image
    the latest version commit is different from the above reply, it's not changes the penultimate check to match any number of whitespace characters. the latest version is invalid.
    can you help me?

  11. SheetJSDev commented on Dec 15, 2020

    @SheetJSDev
    Contributor

    @keithpan does it work if you change the modifier near the end as follows:

    -var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
    +var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg;
                                                                                                    ^

    The caret is marking the modifier that changed. originally it matches up to one whitespace character and the change lets it match any number

  12. keithpan commented on Dec 24, 2020

    @keithpan

    @keithpan does it work if you change the modifier near the end as follows:

    -var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
    +var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg;
                                                                                                    ^

    The caret is marking the modifier that changed. originally it matches up to one whitespace character and the change lets it match any number

    @SheetJSDev
    why does the latest version not have this change?

  13. ansarikhurshid786 commented on Mar 29, 2022

    @ansarikhurshid786

    I am facing same issue when i publish web server. it is working on local server.

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

      Issue actions