Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Silverlight | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

Name Converter

The NameConverter is a static class that provides methods for name conversion (e.g. converting cell names to indexes and vice versa).

Methods

Convert Row Index to Name

ConvertRowIndexToName method converts the row index to name.

Example 1:

int rowIndex = 0; 
string rowName = NameConverter.ConvertRowIndexToName(rowIndex); 

Convert Row Name to Index

ConvertRowNameToIndex method converts the row name to index.

Example 2:

string rowName = "1"; 
int rowIndex = NameConverter.ConvertRowNameToIndex(rowName); 

Convert Column Index to Name

ConvertColumnIndexToName method converts the column index to name.

Example 3:

int columnIndex = 0; 
string columnName = NameConverter.ConvertColumnIndexToName(columnIndex); 

Convert Column Name to Index

ConvertColumnNameToIndex converts the column name to index.

Example 4:

string columnName = "A"; 
int columnIndex = NameConverter.ConvertColumnNameToIndex(columnName); 

Convert Cell Index to Name

ConvertCellIndexToName method converts the cell index to name. This method exposes two overloads.

Example 5: first overload

CellIndex cellIndex = new CellIndex(rowIndex: 0, columnIndex: 0); 
string cellName = NameConverter.ConvertCellIndexToName(cellIndex); 

Example 5: second overload

string cellName = NameConverter.ConvertCellIndexToName(rowIndex: 0, columnIndex: 0); 

Try Convert Names to Cell Reference Range Expression

TryConvertNamesToCellReferenceRangeExpression method tries to convert the cell ranges names to cell reference ranges.

Example 6:

string cellRangesName = "A1:F11"; 
Worksheet worksheet = workbook.ActiveWorksheet; 
int rowIndex = 0; 
int columnIndex = 0; 
CellReferenceRangeExpression expression; 
bool isConversionToCellReferenceRangeExpressionSuccessful = NameConverter.TryConvertNamesToCellReferenceRangeExpression(cellRangesName, worksheet, rowIndex, columnIndex, out expression); 

Convert Cell Reference to Name

ConvertCellReferenceToName method converts the cell reference to name.

Example 7:

CellReference fromCellReference = cellReferenceRangeExpression.CellReferenceRange.FromCellReference; 
string fromCellReferenceName = NameConverter.ConvertCellReferenceToName(fromCellReference); 
 
CellReference toCellReference = cellReferenceRangeExpression.CellReferenceRange.ToCellReference; 
string toCellReferenceName = NameConverter.ConvertCellReferenceToName(toCellReference); 

Convert Cell Range to Name

ConvertCellRangeToName method converts the cell range to a name.

Example 8:

CellIndex fromIndex = new CellIndex(rowIndex: 0, columnIndex: 0); 
CellIndex toIndex = new CellIndex(rowIndex: 10, columnIndex: 5); 
string cellRangeName = NameConverter.ConvertCellRangeToName(fromIndex, toIndex); 

Try Convert Name to Cell Range

TryConvertNameToCellRange method converts the name to a cell range.

Example 9:

CellIndex fromIndex = new CellIndex(rowIndex: 0, columnIndex: 0); 
CellIndex toIndex = new CellIndex(rowIndex: 10, columnIndex: 5); 
string cellRangeName = NameConverter.ConvertCellRangeToName(fromIndex, toIndex); 
 
CellRange cellRange; 
bool result = NameConverter.TryConvertCellRangeNameToCellRange(cellRangeName, out cellRange); 

Convert Cell Indexes to Name

ConvertCellIndexesToName method converts the cell indexes to a name.

Example 10:

string cellRangeName = NameConverter.ConvertCellIndexesToName(fromRowIndex: 0, fromColumnIndex: 0, toRowIndex: 10, toColumnIndex: 5); 

Convert Cell Name to Index

ConvertCellNameToIndex method converts the cell name to a cell index. This method exposes two overloads.

Example 11: first overload

string cellName = "A1"; 
int rowIndex; 
int columnIndex; 
NameConverter.ConvertCellNameToIndex(cellName, out rowIndex, out columnIndex); 

Example 11: second overload

string cellName = "A1"; 
int rowIndex; 
bool isRowAbsolute; 
int columnIndex; 
bool isColumnAbsolute; 
NameConverter.ConvertCellNameToIndex(cellName, out isRowAbsolute, out rowIndex, out isColumnAbsolute, out columnIndex); 

Try Convert Cell Name to Index

TryConvertCellNameToIndex method tries to convert the cell name to index. This method exposes two overloads.

Example 12: first overload

string cellName = "A1"; 
int rowIndex; 
int columnIndex; 
bool isConversionSuccessful = NameConverter.TryConvertCellNameToIndex(cellName, out rowIndex, out columnIndex); 

Example 12: second overload

string cellName = "A1"; 
int rowIndex; 
bool isRowAbsolute; 
int columnIndex; 
bool isColumnAbsolute; 
bool isConversionSuccessful = NameConverter.TryConvertCellNameToIndex(cellName, out isRowAbsolute, out rowIndex, out isColumnAbsolute, out columnIndex); 

Is Valid A1 Cell Name

IsValidA1CellName method determines whether the name of the cell is valid.

Example 13:

string cellName = "B2"; 
bool isValidCellName= NameConverter.IsValidA1CellName(cellName); 

See Also

In this article