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

Fix swapped sheets misnaming #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

marcpeabody
Copy link

@marcpeabody marcpeabody commented Aug 22, 2023

The names of worksheets are saved to an ets table while parsing the workbook. The workbook parser presently uses the sheetId attribute of the sheet tag to match up the worksheet name attribute with its 1-based index position of the corresponding worksheet.

Unfortunately, the sheetId is an unreliable source because it works like a generated primary key on a relational database. This means:

  1. If a sheet ever gets deleted, a gap is left in the sheetId number sequence (1,2,4,5)
  2. If a sheet is ever placed out of order, the sheetId number sequence becomes out of order (1,5,3,2,4)

This can result in the worksheet names not reporting correctly from this framework.

However, the order of the sheet tags in the workbook XML are in the order of the actual given worksheets. This PR relies on the order of the sheet tags in the workbook XML. A test has been added to verify this behavior using an xlsx file created in Excel. Other xlsx files created in Google Sheets and Apple Numbers were also used for manual testing to verify this behavior.

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.

None yet

1 participant