NanoXLSX.Core
3.1.0
Loading...
Searching...
No Matches
CellKey.cs
1
/*
2
* NanoXLSX is a small .NET library to generate and read XLSX (Microsoft Excel 2007 or newer) files in an easy and native way
3
* Copyright Raphael Stoeckli © 2026
4
* This library is licensed under the MIT License.
5
* You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
6
*/
7
8
using
System;
9
10
namespace
NanoXLSX.Internal
11
{
16
internal
readonly
struct
CellKey : IEquatable<CellKey>
17
{
18
internal
readonly
int
Column
;
19
internal
readonly
int
Row;
20
21
internal
CellKey(
int
column,
int
row)
22
{
23
Column
= column;
24
Row = row;
25
}
26
27
public
bool
Equals(CellKey other)
28
{
29
return
Column
== other.Column && Row == other.Row;
30
}
31
32
public
override
bool
Equals(
object
obj)
33
{
34
return
obj is CellKey other && Equals(other);
35
}
36
37
// Excel max: 16 384 columns (14 bits) × 1 048 576 rows (20 bits) — fits cleanly in 34 bits,
38
// so a simple multiply+XOR gives a collision-free hash across the valid address space.
39
public
override
int
GetHashCode()
40
{
41
return
(Row * 16384) ^
Column
;
42
}
43
44
public
override
string
ToString()
45
{
46
return
Cell
.
ResolveCellAddress
(
Column
, Row);
47
}
48
}
49
}
NanoXLSX.Cell
Class representing a cell of a worksheet.
Definition
Cell.cs:23
NanoXLSX.Cell.ResolveCellAddress
static string ResolveCellAddress(int column, int row, AddressType type=AddressType.Default)
Gets the address of a cell by the column and row number (zero based).
Definition
Cell.cs:716
NanoXLSX.Column
Class representing a column of a worksheet.
Definition
Column.cs:18
NanoXLSX.Internal
Definition
CellKey.cs:11
Internal
CellKey.cs
Generated by
1.15.0