Skip to content

Cannot parse file exported from WPS Office (Android) #428

Description

@kedarkarkee

I get a weird bug on trying to parse an excel file exported from WPS Office (Android).

At first, the error was

Null check operator used on null value coming from Line 610 on parser.dart.

It was the null assertion operator on sharedString variable

      case 's':
        final sharedString = _excel._sharedStrings
            .value(int.parse(_parseValue(node.findElements('v').first)));
        value = TextCellValue.span(sharedString!.textSpan);
        break;

I changed it to

      case 's':
        final sharedString = _excel._sharedStrings
            .value(int.parse(_parseValue(node.findElements('v').first)));
        value = TextCellValue.span(sharedString?.textSpan ?? TextSpan(text: 'CHECK'));
        break;

and the parser went through but the rows are mismatched.

My excel file is like this

Image

The parser output is (converted to strings)

[Item Name, Category, Sales Price, Purchase Price, Opening Stock, Low Stock, Item Code, HS code, Description]
[Coca Cola 2L, Drinks, 120, 80, 25, 5, null, 12893773.0, Best drinks]
[Fanta 1L, Drinks, 100, 70, 30, null, null, null, null]
[Mountain Dew 1L, null, 110, 75, 15, 10, MD1, 939783, null]
[Real Juice 250ml, General, 50, 35, 60, null, null, null, Fruit Juice]
[null, bbb, null, null, null, null, null, 8.9, null]
[null, hhh, null, null, null, null, null, hsgs8282, null]
[null, hhhh, null, null, null, null, null, CHECK, null]
[null, 8.9.8, null, null, null, null, null, null, null]

Notice the last three rows on the file and on the parsed data, Also notice the CHECK keyword I added to fix null assertion keyword.

The file is

wpsExportedExample.xlsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions