Conversion between cell name and row/column index

How to Get Cell Name from Row and Column Indices

It is possible to find a cell’s name given the row and column index. This article explains how.

Aspose.Cells provides the CellsHelper.cellIndexToName method which allows developers to get a cell’s name if they provide the row and column indices.

The following sample code illustrates how to use CellsHelper.cellIndexToName to access the cell’s name given a known row and column index. The code generates the following output.

Cell Name at [0, 0]: A1

Cell Name at [4, 0]: A5

Cell Name at [0, 4]: E1

Cell Name at [2, 2]: C3

How to Get Row and Column Indices from Cell Name

It is possible to find the row and column indices of a cell from its name. This article explains how.

Aspose.Cells provides the CellsHelper.cellNameToIndex method which allows developers to get the row and column indices from the cell’s name.

The following sample code illustrates how to use CellsHelper.cellNameToIndex to get the row and column indices from the cell’s name. The code generates the following output.

Row Index of Cell C6: 5

Column Index of Cell C6: 2

How to Create Safe Sheet Names

Sometimes there is a need to assign the sheet name at runtime. In this scenario, sheet names may contain additional characters such as <>+("?. There is a need to replace any such character that is not allowed in a sheet name with a preset character provided by the user. Similarly, if the length exceeds 31 characters, it needs to be truncated. Apache POI provides certain features for creating safe names; Aspose.Cells provides a similar feature to handle these issues. The following sample code demonstrates this feature:

Console Output

this is first name which is cre

 <> + (adj.Private _ " Private"