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

Closes #2460: Compatibility with libre office files #2472

Merged
merged 6 commits into from
May 16, 2024

Conversation

diasf
Copy link
Contributor

@diasf diasf commented Apr 30, 2024

Make xslx reader compatible with files created by libre office.

Handled issues:

  • Reader was fetching sheet with hard-coded id (rId1). However the id of a sheet is configurable and can be set as desired by applications creating the xslx. In this case excel starts sheet ids with rId1, rId2, ... whereas libre starts at rId2. The fix uses getSheetData to just fetch the first sheet.
  • Excel includes a spans attribute for each row indicating how many columns it contains. This was used to allocate an array for the column names. Unfortunately, libre office doesn't include this attribute. The fix replaces the array with a TreeMap allowing to collect the column names as we parse them.

Issue: #2460


// then
assertThat(result.getDataTable().getVarQuantity()).isEqualTo(5);
assertThat(result.getDataTable().getDataVariables().stream().map(DataVariable::getName).collect(Collectors.toList()))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a change request.
We could have also write it in a little shorter way:
`assertThat(result.getDataTable().getDataVariables()).extracting(DataVariable::getName)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that's much better. Changed it.

@madryk madryk removed their assignment May 16, 2024
@diasf diasf merged commit d9ea0df into develop May 16, 2024
1 check passed
@diasf diasf deleted the fdias-2460-xslx-reader-compatibility-with-libre-office branch May 16, 2024 14:33
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.

2 participants