Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ttilberg
Copy link
Contributor

@ttilberg ttilberg commented Jul 2, 2019

This fixes #506 where expand_merged_ranges: true was shown to create nil in the @cells hash. This then would cause other issues where cell objects were expected to exist (such as during clean: true).

@ttilberg ttilberg changed the title Only copy if cell is present when expand_merged_cells: true Only copy if cell is present when expand_merged_ranges: true Jul 2, 2019
@ttilberg
Copy link
Contributor Author

ttilberg commented Jul 2, 2019

Hello, I see that there are tests available for expand_merged_ranges at test/roo/test_excelx.rb:101 -- but I'm hesitant to alter test/files/merged_ranges.xls as I don't have Excel (only LibreOffice).

Is this okay? I'd like to figure out how to add a test for this to assert that we don't copy nil cells.

Or should I just add the example file from the issue?

@ttilberg
Copy link
Contributor Author

ttilberg commented Jul 2, 2019

I haven't looked at this, but if doc.xpath('/worksheet/mergeCells/mergeCell') is able to filter to nodes with content, this would prevent us from doing the work at all. I'll check this when I get back to my desk.

@ttilberg
Copy link
Contributor Author

ttilberg commented Jul 2, 2019

I just looked into filter during node selection, but there does not appear to be any difference:

[3] pry(#<Roo::Excelx::SheetDoc>)> doc.xpath('/worksheet/mergeCells').to_xml
=> "<mergeCells count=\"2\">\n  <mergeCell ref=\"B3:B4\"/>\n  <mergeCell ref=\"B5:B6\"/>\n</mergeCells>"

@coveralls
Copy link

coveralls commented Jul 2, 2019

Coverage Status

Coverage increased (+0.04%) to 94.403% when pulling 15826d6 on ttilberg:506-dont-expand-merged-nil into 4ec1104 on roo-rb:master.

@ttilberg ttilberg force-pushed the 506-dont-expand-merged-nil branch from 2acee5a to 15826d6 Compare July 3, 2019 04:03
If you merge empty cells, the definitions for merged ranges references
the appropriate coordinates for the merge, but the cells hash does not
include a value at that coordinate. When copying the src to dst, we end
up copying `nil` into the `cells` hash which causes errors in several
other parts of parsing.
@ttilberg
Copy link
Contributor Author

ttilberg commented Jul 3, 2019

Hello, I see that there are tests available for expand_merged_ranges at test/roo/test_excelx.rb:101 -- but I'm hesitant to alter test/files/merged_ranges.xls as I don't have Excel (only LibreOffice).

Is this okay? I'd like to figure out how to add a test for this to assert that we don't copy nil cells.

Or should I just add the example file from the issue?

I just pushed a commit with a test for this condition, which included me editing test/files/merged_ranges.xls in LibreOffice to include a merged range without content. I want to be explicit about this change to this file in case it is not appropriate to have edited it with LibreOffice (or at all). If you wish a separate file is created, I'd be happy to send that instead, but it felt unnecessary.

@ttilberg
Copy link
Contributor Author

ttilberg commented Aug 19, 2019

@chopraanmol1 / @amoniacou would you mind taking a look at this? I was asked by a coworker if this patch was accepted yet and I noticed this hasn't been looked at yet. I'd love to make whatever changes necessary to get this accepted. Thanks!

@ttilberg
Copy link
Contributor Author

@chopraanmol1 Can you please review this, or ping someone else that might be appropriate to review and accept this PR? Thank you for your time.

@simonoff simonoff merged commit 573d02e into roo-rb:master Aug 18, 2020
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.

Error when opening file with expand_merged_ranges and parse with clean option

4 participants