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

lxls parser doesn't like ODS files generated by numbers.app #94

Open
rossjones opened this issue Oct 2, 2024 · 1 comment
Open

lxls parser doesn't like ODS files generated by numbers.app #94

rossjones opened this issue Oct 2, 2024 · 1 comment

Comments

@rossjones
Copy link
Collaborator

rossjones commented Oct 2, 2024

They fail with

 console.error
      ODS number format may be incorrect: value()<0

      40 | // Set the filename of the file for an import session.
      41 | exports.SessionSetFile = (sid, filename) => {
    > 42 |   const wb = xlsx.readFile(filename, {dense: true, cellStyles: true});
         |                   ^
      43 |
      44 |   let session = {
      45 |     filename: filename,

      at parse_ods_styles (node_modules/xlsx/xlsx.js:22883:17)
      at parse_ods (node_modules/xlsx/xlsx.js:23457:25)
      at parse_zip (node_modules/xlsx/xlsx.js:26352:58)
      at read_zip (node_modules/xlsx/xlsx.js:26919:9)
      at readSync (node_modules/xlsx/xlsx.js:26997:69)
      at Object.readFileSync (node_modules/xlsx/xlsx.js:27025:9)
      at Object.readFile [as SessionSetFile] (backend.js:42:19)
      at Object.SessionSetFile (backend.test.js:360:13)

This is described at SheetJS/sheetjs#1569 and so there may be a solution there somewhere

The actual responsible code is at https://github.com/SheetJS/sheetjs/blob/08f5678c9881efbe0dd7b482cb7df4a72843fba8/bits/80_parseods.js#L222-L223

@rossjones
Copy link
Collaborator Author

The repo is now at https://git.sheetjs.com/sheetjs/sheetjs

The responsible code is at https://git.sheetjs.com/sheetjs/sheetjs/src/branch/master/bits/80_parseods.js#L204-L209

case 'map': // <style:map> 16.3
    // TODO: handle more complex maps
    y = parsexmltag(Rn[0], false);
    if(unescapexml(y["condition"]) == "value()>=0") NF = number_format_map[y["apply-style-name"]] + ";" + NF;
    else console.error("ODS number format may be incorrect: " + y["condition"]);
    break;

The ODS file we are testing with has this within the number style

<number:text-style style:name="N128">
    <number:text loext:blank-width-char="-"> </number:text>
    <number:text-content />
    <number:text loext:blank-width-char="-"> </number:text>
    <style:map style:condition="value()&gt;0" style:apply-style-name="N128P0" />
    <style:map style:condition="value()&lt;0" style:apply-style-name="N128P1" />
    <style:map style:condition="value()=0" style:apply-style-name="N128P2" />
</number:text-style>

which suggests the parser is supposed to evaluate the condition and then apply the referenced style. The code in sheetjs seems to misinterpret the meaning of this tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant