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

Free Support Forum - aspose.com

How to get the Active cell on based of RowNumber and ColNubmer

Hi Team,

How can we set the Active cell on based of the RowNumber and ColNumber in Aspose.

Thanks,

AsposeEvaluation

Hi Gurdeep,


Thank you for contacting Aspose support.

The Worksheet.setActiveCell method accepts the cell name in string format. Therefore if you wish to set the ActiveCell using the row & column numbers, you have to first convert the column number to column name using the CellsHelper.columnIndexToName method. The row will remain as number but keep in mind that Excel rows starts from 1 whereas in reference to Aspose.Cells API, the rows have 0 based index.

Java
//Instantiate a new Workbook
Workbook workbook = new Workbook();

//Get the first default sheet
Worksheet sheet = workbook.getWorksheets().get(0);

int row = 2;

int col = 1;

//Convert the Column Index/Number to Column Name
//and append the Row Number to get the Cell Name
sheet.setActiveCell(CellsHelper.columnIndexToName(col) + row);

The above code snippet sets the B2 as active cell. Please feel free to write back in case you face any difficulty.