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

Xlsxir reads the wrong sheet name from workbook created with Elixlsx #93

Open
norpan opened this issue Jul 22, 2019 · 4 comments
Open

Comments

@norpan
Copy link

norpan commented Jul 22, 2019

I'm not sure if the bug is with Elixlsx or with Xlsxir, but the file works when opened in Excel.

bug.xlsx

iex(19)> %Elixlsx.Workbook{sheets: [%Elixlsx.Sheet{name: "Sheet1", rows: [["A"]]}, %Elixlsx.Sheet{name: "Sheet2", rows: [["A"], ["B"]]}]} |> Elixlsx.write_to("bug.xlsx")
{:ok, 'bug.xlsx'}
iex(20)> [{:ok, sheet1}, {:ok, sheet2}] = Xlsxir.multi_extract("bug.xlsx")
[
  ok: #Reference<0.1684016233.731512836.50328>,
  ok: #Reference<0.1684016233.731512836.50330>
]
iex(21)> Xlsxir.get_info(sheet1)
[rows: 1, cols: 1, cells: 1, name: nil]
iex(22)> Xlsxir.get_info(sheet2)
[rows: 2, cols: 1, cells: 2, name: "Sheet1"]
@xavier
Copy link

xavier commented Nov 6, 2019

I've encountered the same error. It's not a parsing problem: the attributes are correctly extracted and stored in the workbook ETS table. The issue occurs when retrieving the name of the sheet being parsed to populate the {:info, :worksheet_name, ...} tuple stored the sheet ETS table.

This library seems to assume that the sheets are named sheet<rid>.xml which is apparently not standard behavior.

It might work on a lucky day but it is entirely depending on the implementation of the software writing the package.

For instance, an xlsx file written by Apple Numbers uses the sheetId attribute as a file basename suffix (and it looks like Elixlsx does the same. In that case, using sheet_id instead of rid as ETS table key fixes it.

I suppose that the only reliable solution is to rely on the explicit mapping provided in _rels/workbook.xml.rels to map sheet XML files with their corresponding r:id.

@grantwest
Copy link

Since there hasn't been activity on this for quite some time, I'll just mention here for others visiting this issue, it has not been resolved as of this comment.

@larshei
Copy link

larshei commented Feb 10, 2024

Got the same problem :)

@maysam
Copy link

maysam commented Apr 27, 2024

when I download xlsx file from google sheets, it works fine
but when I download xlsx file from sharepoint, I get this error

what made this a disaster for me was that I relied on the sheet labels

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

5 participants