tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.49k stars 418 forks source link

The streaming cell now always begins with a clean state when using the xlnt::streaming_workbook_reader #599

Closed doomlaur closed 2 years ago

doomlaur commented 2 years ago

Example of XML code from an Excel sheet:

<c r="G4" s="5" t="s">
    <v>45</v>
</c>
<c r="H4"/>
<c r="I4" s="1">
    <v>3</v>
</c>

When using the xlnt::streaming_workbook_reader, the streamingcell was previously reused, but was overwritten with information from the new cell. In the example above, reading cell G4 would read a shared_string at index 45. Cell H4 is a cell with no information except its reference, and would previously cause XLNT to return cell H4 with the information from cell G4.

The simple fix I provided resets the cell state, so that the streaming cell always begins with a clean state, just as it happens when not streaming.

doomlaur commented 2 years ago

I just noticed that I created the pull request from the wrong branch. I'll open a new one that just contains this fix.