[0.11.2] Plain text parsing gives strange results #781

Closed
opened 2017-08-17 09:01:49 +00:00 by the-spyke · 1 comment
the-spyke commented 2017-08-17 09:01:49 +00:00 (Migrated from github.com)

Version [0.11.2] has plain text parsing enabled by default.

  1. The default value for raw setting isn't specified in Parser Options table
  2. Its behavior is strange

Source

const workbook = XLSX.read(base64String, {
    type: "base64",
    cellHTML: false,
    cellText: false,
});

Input CSV

sku,day,store,color,sales
sku 24,20120101,store-1,blue,$44.00

Result workbook object

{
    "SheetNames": [
        "Sheet1"
    ],
    "Sheets": {
        "Sheet1": {
            "A1": {
                "t": "s",
                "v": "sku"
            },
            "B1": {
                "t": "s",
                "v": "day"
            },
            "C1": {
                "t": "s",
                "v": "store"
            },
            "D1": {
                "t": "s",
                "v": "color"
            },
            "E1": {
                "t": "s",
                "v": "sales"
            },
            "A2": {
                "t": "s",
                "v": "sku 24"
            },
            "B2": {
                "t": "n",
                "w": "20120101",
                "v": 20120101
            },
            "C2": {
                "z": "m/d/yy",
                "t": "n",
                "v": 36892,
                "w": "1/1/01"
            },
            "D2": {
                "t": "s",
                "v": "blue"
            },
            "E2": {
                "t": "n",
                "w": "$44.00",
                "v": 44
            },
            "!ref": "A1:E2"
        }
    }
}

What's wrong

  • store-1 is parsed as 36892
  • It's cell has z property even if cellNF is false by default
  • Some cells have w property even if cellText is false in supplied options object

Conclusions

  • Not sure if raw should be false by default, but I'm fine with that
  • Please add the default value for it into the Parser Options table
  • Need to update plain text parsing logic?
Version [0.11.2] has plain text parsing enabled by default. 1. The default value for `raw` setting isn't specified in `Parser Options` table 2. Its behavior is strange ## Source ``` const workbook = XLSX.read(base64String, { type: "base64", cellHTML: false, cellText: false, }); ``` ## Input CSV ``` sku,day,store,color,sales sku 24,20120101,store-1,blue,$44.00 ``` ## Result workbook object ``` { "SheetNames": [ "Sheet1" ], "Sheets": { "Sheet1": { "A1": { "t": "s", "v": "sku" }, "B1": { "t": "s", "v": "day" }, "C1": { "t": "s", "v": "store" }, "D1": { "t": "s", "v": "color" }, "E1": { "t": "s", "v": "sales" }, "A2": { "t": "s", "v": "sku 24" }, "B2": { "t": "n", "w": "20120101", "v": 20120101 }, "C2": { "z": "m/d/yy", "t": "n", "v": 36892, "w": "1/1/01" }, "D2": { "t": "s", "v": "blue" }, "E2": { "t": "n", "w": "$44.00", "v": 44 }, "!ref": "A1:E2" } } } ``` ## What's wrong - `store-1` is parsed as `36892` - It's cell has `z` property even if `cellNF` is `false` by default - Some cells have `w` property even if `cellText` is `false` in supplied options object ## Conclusions - Not sure if `raw` should be `false` by default, but I'm fine with that - Please add the default value for it into the `Parser Options` table - Need to update plain text parsing logic?
SheetJSDev commented 2017-08-18 18:19:27 +00:00 (Migrated from github.com)
  • README updated to mention that raw defaults to false
  • CSV parsing honors cellText and cellNF

Most of the ancillary options were initially added to XLSX or XLS but haven't been propagated to the other formats.

- [README](https://github.com/sheetjs/js-xlsx#parsing-options) updated to mention that `raw` defaults to `false` - CSV parsing honors `cellText` and `cellNF` Most of the ancillary options were initially added to XLSX or XLS but haven't been propagated to the other formats.
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#781
No description provided.