New to Telerik Document ProcessingStart a free 30-day trial

Converts between zero-based cell indices and Excel A1-style names (e.g., row 0 / column 1 to "B1") for use in formulas and display.

Definition

Namespace:Telerik.Windows.Documents.Spreadsheet.Utilities

Assembly:Telerik.Windows.Documents.Spreadsheet.dll

Syntax:

C#
public static class NameConverter

Inheritance: objectNameConverter

Methods

Formats zero-based row and column indices into an A1-style range name (e.g., "A1:B10").

C#
public static string ConvertCellIndexesToName(int fromRowIndex, int fromColumnIndex, int toRowIndex, int toColumnIndex)
Parameters:fromRowIndexint

The start row index.

fromColumnIndexint

The start column index.

toRowIndexint

The end row index.

toColumnIndexint

The end column index.

Returns:

string

The name.

Formats a CellIndex into an A1-style cell name (e.g., row 0, column 1 to "B1").

C#
public static string ConvertCellIndexToName(CellIndex cellIndex)
Parameters:cellIndexCellIndex

The cell index.

Returns:

string

The name.

Combines a zero-based row and column index into an A1-style cell name (e.g., row 0, column 1 to "B1").

C#
public static string ConvertCellIndexToName(int rowIndex, int columnIndex)
Parameters:rowIndexint

Index of the row.

columnIndexint

Index of the column.

Returns:

string

The name.

Parses an A1-style cell name into zero-based indices and detects absolute reference markers (e.g., "$A$1" sets both flags true).

C#
public static void ConvertCellNameToIndex(string cellName, out bool isRowAbsolute, out int rowIndex, out bool isColumnAbsolute, out int columnIndex)
Parameters:cellNamestring

Name of the cell.

isRowAbsolutebool

The value indicating whether the row is absolute.

rowIndexint

Index of the row.

isColumnAbsolutebool

The value indicating whether the column is absolute.

columnIndexint

Index of the column.

Parses an A1-style cell name (e.g., "B1") into zero-based row and column indices, throwing on invalid input.

C#
public static void ConvertCellNameToIndex(string cellName, out int rowIndex, out int columnIndex)
Parameters:cellNamestring

Name of the cell.

rowIndexint

Index of the row.

columnIndexint

Index of the column.

Formats a cell range into an A1-style name (e.g., "A1:B10"), detecting full-row or full-column ranges.

C#
public static string ConvertCellRangeToName(CellIndex fromIndex, CellIndex toIndex)
Parameters:fromIndexCellIndex

From index.

toIndexCellIndex

To index.

Returns:

string

The name.

Formats a CellRange into an A1-style name (e.g., "A1:B10"), detecting full-row or full-column ranges.

C#
public static string ConvertCellRangeToName(CellRange range)
Parameters:rangeCellRange

The range.

Returns:

string

The name.

Formats a range defined by two CellReferences into an A1-style name, preserving absolute markers (e.g., "$A$1:$B$10").

C#
public static string ConvertCellReferenceRangeToName(CellReference fromCellReference, CellReference toCellReference)
Parameters:fromCellReferenceCellReference

The start cell reference.

toCellReferenceCellReference

The end cell reference.

Returns:

string

The name.

Formats a CellReference into an A1-style name, preserving absolute reference markers (e.g., $A$1).

C#
public static string ConvertCellReferenceToName(CellReference cellReference)
Parameters:cellReferenceCellReference

The cell reference.

Returns:

string

The name.

Converts a zero-based column index to its Excel alphabetic column name (e.g., 0 to "A", 25 to "Z", 26 to "AA").

C#
public static string ConvertColumnIndexToName(int columnIndex)
Parameters:columnIndexint

Index of the column.

Returns:

string

The name.

Parses an Excel alphabetic column name (e.g., "A", "Z", "AA") to a zero-based column index, throwing on invalid input.

C#
public static int ConvertColumnNameToIndex(string columnName)
Parameters:columnNamestring

Name of the column.

Returns:

int

The index.

Converts a zero-based row index to its 1-based Excel row name (e.g., 0 to "1", 999 to "1000").

C#
public static string ConvertRowIndexToName(int rowIndex)
Parameters:rowIndexint

Index of the row.

Returns:

string

The name.

Parses a 1-based Excel row name (e.g., "1", "1000") to a zero-based row index, throwing on invalid input.

C#
public static int ConvertRowNameToIndex(string rowName)
Parameters:rowNamestring

Name of the row.

Returns:

int

The index.

Validates whether a string is a valid A1-style cell name (e.g., "A1", "$B$10") within worksheet bounds.

C#
public static bool IsValidA1CellName(string cellName)
Parameters:cellNamestring

Name of the cell.

Returns:

bool

The value indicating whether the name of the cell is valid.

Tries to parse an A1-style cell name into indices and absolute flags, returning false if invalid.

C#
public static bool TryConvertCellNameToIndex(string cellName, out bool isRowAbsolute, out int rowIndex, out bool isColumnAbsolute, out int columnIndex)
Parameters:cellNamestring

Name of the cell.

isRowAbsolutebool

The is row absolute.

rowIndexint

Index of the row.

isColumnAbsolutebool

The is column absolute.

columnIndexint

Index of the column.

Returns:

bool

Tries to parse an A1-style cell name (e.g., "B1") into zero-based indices, returning false if invalid or out of range.

C#
public static bool TryConvertCellNameToIndex(string cellName, out int rowIndex, out int columnIndex)
Parameters:cellNamestring

Name of the cell.

rowIndexint

Index of the row.

columnIndexint

Index of the column.

Returns:

bool

The value indicating whether the conversion was successful.

Tries to parse an A1-style range name (e.g., "A1:B10", "1:5", "A:C") into a CellRange, returning false if invalid.

C#
public static bool TryConvertCellRangeNameToCellRange(string name, out CellRange cellRange)
Parameters:namestring

The cell range name.

cellRangeCellRange

The CellRange instance.

Returns:

bool

True if successful, otherwise False.

Parses a cell range name string (e.g., "A1:B10") into a CellReferenceRangeExpression relative to the specified cell position, returning false if invalid.

C#
public static bool TryConvertNamesToCellReferenceRangeExpression(string cellRangesNames, Worksheet worksheet, int rowIndex, int columnIndex, out CellReferenceRangeExpression expression)
Parameters:cellRangesNamesstring

The cell ranges names.

worksheetWorksheet

The worksheet.

rowIndexint

The row index of the cell for which the expression is created.

columnIndexint

The column index of the cell for which the expression is created.

expressionCellReferenceRangeExpression

The expression.

Returns:

bool

True if converter successfuly, else false.