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

Free Support Forum - aspose.com

Previous and Next Column

I don’t see a way to get the previous or next column when the columns potentially could be merged. Am I missing something? Seems like that would be a highly used method.

Hi,


Well, you may use Cell.IsMerged boolean property to know if a cell is merged or not. You may loop through your worksheet’s range of cells to do what you want to do. For example to get the next cell of the merged cell (row, col) can be obtained by adding +1 to the cell’s column index portion. See the code segment below:

//…
Cells cells = worksheet.Cells;

for (int y = 0; y <= cells.MaxRow; y++)
{
for (int x = 0; x <= cells.MaxColumn; x++)
{
Cell cell = cells[y, x];
object value;
if (cell.IsMerged)
{
value = “Merged”;
MessageBox.Show(cell.Name);
}
}
}

Also, please see the article on how to get the merged cells list with their cell areas in worksheets:
http://www.aspose.com/docs/display/cellsnet/Detect+Merged+Cells+in+a+Worksheet