I'm trying to implement code in Perl to parse a large Excel sheet as the below Excel example:
For example, in the attached image you can see that 3 elements are assigned as named "rsvd"
"frame_kind"
and "destination"
.
So I want to make a data structure with the size of a merged excel cell in Perl.
eg) what I want to get the information is that rsvd
has merged from 16 to 31 and the size of rsvd
16.
frame_kind
has merged from 14 to 15 and the size of frame_kind
2.
destination
has merged from 0 to 13 and the size of destination
14.
How can I get the location of a cell a certain merged number of cells away and size in Perl?
CodePudding user response:
The Spreadsheet::ParseExcel module has a get_cell
method which returns a Cell object. The Cell object does not look like it directly tells how big it is, but you can use the value
and is_merged
methods to determine the size of the merged cells.
Start at the expected cell (C6
in your example), then loop through the columns in Row 6, checking the value and whether the cell is merged. The value will start at rsvd
, and once the value is not rsvd
, you know you found the end of the 1st merged cell. Repeat this loop for the remaining columns in the row to get all merged cells.