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

Free Support Forum - aspose.com

How to loop cells

Hi, how can I loop through all the rows and columns of a xls spreadsheet?

Can you help me?


Thanks for considering Aspose.

You mean, you want to loop through all the cells with data in rows/columns in a worksheet of your template file. Well, you may use MaxDataRow and MaxDataColumn properties of the Cells class.

(Sample code) E.g.,

Workbook workbook = new Workbook();
Worksheet ws = workbook.Worksheets[0];
for (int row=0;row<=ws.Cells.MaxDataRow;row++)
for (int col =0;col<= ws.Cells.MaxDataColumn; col++ )
//Your code goes here........
if (ws.Cells[row,col].StringValue == "mydata")


Thank you.