We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Cells Java - Merged Cells

Hi there,


I need to get the number of rows and columns that belong to a merged cell. How I can get these values?

Thanks.
Cheers,
RMRodrigues

Hi,


Thanks for your query.

Well, you may try to use Cell.getMergedRange() method to get the range of the merged cell. You may then use Range.getRowCount() and Range.getColumnCount() methods to get the number of rows and columns a range has, see the sample code segment for your reference:
e.g
Sample code:


Range range = cell.getMergedRange();


for (int i = range.getFirstRow(); i < range.getFirstRow() + range.getRowCount(); i++)

{

for (int j = range.getFirstColumn(); j < range.getFirstColumn() + range.getColumnCount(); j++)

{
//Get the individual cells in the merged range of cells.
Cell rcell = worksheet.getCells().get(i, j);
//…
// Your code goes here.
//…

}

}

Hope, this helps a bit.

Thank you.

Thank you so much.

Hi,


You are welcome. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.