Merged cells are a little bit of a red herring. Sometimes you want to access the actual cells rather than the reference/the MergedCell's. For example to obtain indivual borders for each of the cells in the merge. Which is required to be able to obtain the exact borders.
In doing this work, I have found the following method useful. It may be a desirable inclusion in the library, probably under a more sophisticated form.
def merged_cells(cell)
return nil unless cell.worksheet.merged_cells
cell.worksheet.merged_cells.each { |mcell|
if mcell.ref.first_row == cell.row && mcell.ref.first_col == cell.column
return mcell.ref.row_range.collect { |row|
mcell.ref.col_range.collect { |col|
cell.worksheet[row][col]
}
}
end
}
nil
end
Merged cells are a little bit of a red herring. Sometimes you want to access the actual cells rather than the reference/the MergedCell's. For example to obtain indivual borders for each of the cells in the merge. Which is required to be able to obtain the exact borders.
In doing this work, I have found the following method useful. It may be a desirable inclusion in the library, probably under a more sophisticated form.