NanoXLSX.Core
3.2.1
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
26
internal
CellKey(
int
column,
int
row)
27
{
28
Column
= column;
29
Row = row;
30
}
31
37
public
bool
Equals(CellKey other)
38
{
39
return
Column
== other.Column && Row == other.Row;
40
}
41
47
public
override
bool
Equals(
object
obj)
48
{
49
return
obj is CellKey other && Equals(other);
50
}
51
52
// Excel max: 16 384 columns (14 bits) × 1 048 576 rows (20 bits) — fits cleanly in 34 bits,
53
// so a simple multiply+XOR gives a collision-free hash across the valid address space.
58
public
override
int
GetHashCode()
59
{
60
return
(Row * 16384) ^
Column
;
61
}
62
67
public
override
string
ToString()
68
{
69
return
Cell
.
ResolveCellAddress
(
Column
, Row);
70
}
71
}
72
}
NanoXLSX.Cell
Class representing a cell of a worksheet.
Definition
Cell.cs:25
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:855
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