API Reference

Class

A1

Namespace OfficeIMO.Excel
Assembly OfficeIMO.Excel
Modifiers static

Utility helpers for parsing and converting Excel A1 references. Public so examples and consumers can reuse consistent logic without re-implementing regexes or math.

Inheritance

  • Object
  • A1

Methods

public static String ColumnIndexToLetters(Int32 index) #
Returns: String

Converts a 1-based column index to Excel column letters (e.g., 1→"A", 27→"AA").

Parameters

index System.Int32 requiredposition: 0
1-based column index.

Returns

Excel column letters; returns "A" for non-positive inputs.

Examples

string col = A1.ColumnIndexToLetters(28); // "AB" int idx = A1.ColumnLettersToIndex("AB"); // 28

public static Int32 ColumnLettersToIndex(String letters) #
Returns: Int32

Converts column letters (e.g., "A", "AA") to a 1-based column index. Non-letter characters are ignored; returns 0 for empty/invalid input.

Parameters

letters System.String requiredposition: 0
Excel column letters.

Returns

1-based column index, or 0 when input yields no letters.

public static ValueTuple<Int32, Int32> ParseCellRef(String cellRef) #
Returns: ValueTuple<Int32, Int32>

Parses a single A1 cell reference (e.g., "B5") into a 1-based (row, column) tuple. Returns (0,0) when the input does not match a valid simple cell reference.

Parameters

cellRef System.String requiredposition: 0
A1 cell reference, without sheet prefix.

Returns

Tuple of row and column (1-based). Returns (0,0) if invalid.

public static ValueTuple<Int32, Int32, Int32, Int32> ParseRange(String a1Range) #
Returns: ValueTuple<Int32, Int32, Int32, Int32>

Parses an A1 range (e.g., "A1:B10") into 1-based, normalized bounds. If the bounds are inverted, they are swapped so that r1 <= r2 and c1 <= c2.

Parameters

a1Range System.String requiredposition: 0
A1 range string, without sheet prefix.

Returns

(r1, c1, r2, c2) 1-based coordinates.

Exceptions

  • ArgumentException – Thrown when the input is not a valid A1 range.

Examples

var (r1, c1, r2, c2) = A1.ParseRange("B2:D10"); // r1=2, c1=2, r2=10, c2=4

public static Boolean TryParseRange(String a1Range, out Int32 r1, out Int32 c1, out Int32 r2, out Int32 c2) #
Returns: Boolean

Tries to parse an A1 range (e.g., "A1:B10") into 1-based, normalized bounds. Returns false when the input is not a valid A1 range.

Parameters

a1Range System.String requiredposition: 0
r1 System.Int32@ requiredposition: 1
c1 System.Int32@ requiredposition: 2
r2 System.Int32@ requiredposition: 3
c2 System.Int32@ requiredposition: 4