Skip to content

handle duplicate shared strings - #437

Open
davidskelly wants to merge 1 commit into
justkawal:mainfrom
davidskelly:shared-strings-fix
Open

davidskelly wants to merge 1 commit into
justkawal:mainfrom
davidskelly:shared-strings-fix

Conversation

@davidskelly

@davidskelly davidskelly commented Dec 28, 2025

Copy link
Copy Markdown

Trying to read an excel file not created by me, sharedString is null.

Unhandled exception:
Null check operator used on a null value
#0      Parser._parseCell (package:excel/src/parser/parse.dart:614:48)
#1      Parser._parseRow.<anonymous closure> (package:excel/src/parser/parse.dart:578:7)
#2      Iterable.forEach (dart:core/iterable.dart:366:35)
#3      Parser._parseRow (package:excel/src/parser/parse.dart:577:22)
#4      Parser._parseTable.<anonymous closure> (package:excel/src/parser/parse.dart:557:7)
#5      Iterable.forEach (dart:core/iterable.dart:366:35)
#6      Parser._parseTable (package:excel/src/parser/parse.dart:556:22)
#7      Parser._parseContent.<anonymous closure> (package:excel/src/parser/parse.dart:156:9)
Screenshot from 2025-12-27 22-16-02

This appears to be the case when xl/sharedStrings.xml contains duplicate entries, eg

<si>
        <t>Entry Here</t>
    </si>
<si>
        <t>Entry Here</t>
    </si>

A code change like value = sharedString == null ? null : TextCellValue.span(sharedString!.textSpan); allows the document to parse, but now fetching certain cells point to the incorrect index and will return the wrong text - basically a corrupted document. So this is not the correct fix.

When adding a shared string, adding it to the _list always, even if it's a duplicate, fixes the null pointer exception and fixes the text retrieval of the cells that were retrieving incorrect text values before.

Same as this issue: #435 #433
Related to these prs: #434 #436

@menghinidev

Copy link
Copy Markdown

Can we get an ETA on this? @justkawal @justraman

@menghinidev

Copy link
Copy Markdown

Please @justkawal @justraman give at least a feedback that you received the request.
There are several PRs on this matter waiting for your approval and code review.

@prcwak

prcwak commented Mar 13, 2026

Copy link
Copy Markdown

It works for me.
prcwak@d3ab813

@gonojuarez

Copy link
Copy Markdown

@davidskelly I created a fork of Flutter Excel. The name is excel_community you can find it here link

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants