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

cell inlineStr parsing problem at the beginning of the file #131

Open
lowercase opened this issue Nov 14, 2024 · 4 comments
Open

cell inlineStr parsing problem at the beginning of the file #131

lowercase opened this issue Nov 14, 2024 · 4 comments

Comments

@lowercase
Copy link

lowercase commented Nov 14, 2024

I found a problem with inlineStr parsing, when we get a spreadsheet with

<sheetData><row r="1"><c r="A1" s="1" type="inlineStr"><is><t>Value1</t></is></c><c r="B1" s="1" type="inlineStr"><is><t>Value2</t></is></c>...

the whole row will be [nil, nil, ...]
but if we change only the first cell to

<c r="A1" s="1" type="inlineStr"><v>Value1</v></c><c r="B1" s="1" type="inlineStr"><is><t>Value2</t></is></c>...

the whole row will parse ["Value1", "Value2"...]

how to fix this behavior?

@lowercase
Copy link
Author

lowercase commented Nov 14, 2024

if add

> # xlsxir/lib/xlsxir/parse_worksheet.ex
> def sax_event_handler({:startElement, _, 't', _, _}, state, _, _) do                                                                                                                                                   
>      %{state | value_type: :value}                                                                                                                                                                                        
> end

what will it break?

@lowercase
Copy link
Author

lowercase commented Nov 14, 2024

def sax_event_handler({:startElement, _, 'c', _, xml_attr}, state, %{styles: styles_tid}, _) do
      .....
      %{state | cell_ref: cell_ref, num_style: num_style, data_type: data_type, value_type: nil}
end

and maybe value_type should be nullified for new cell

@lowercase
Copy link
Author

Oh, I see that it's already fixed in master. But there are still bugs in 1.6.4

@lowercase
Copy link
Author

In master branch there is another problem: since stream_worksheet.ex has its own def sax_event_handler({:endElement, _, 'row', _}, state, _excel), it does not fill_nil like parse_worksheet.ex. So for {A1: 1, C1: 2} instead of [1, nil, 2] I get [1,2].

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

No branches or pull requests

1 participant