@@ -10,59 +10,106 @@ public sealed class Cell
10
10
private readonly DocumentFormat . OpenXml . Spreadsheet . Cell _cell ;
11
11
private readonly SheetData _sheetData ;
12
12
13
+ /// <summary>
14
+ /// Gets the cell reference in A1 notation.
15
+ /// </summary>
13
16
public string CellReference => _cell . CellReference ;
14
17
18
+ /// <summary>
19
+ /// Initializes a new instance of the <see cref="Cell"/> class.
20
+ /// </summary>
21
+ /// <param name="cell">The underlying OpenXML cell object.</param>
22
+ /// <param name="sheetData">The sheet data containing the cell.</param>
23
+ /// <exception cref="ArgumentNullException">
24
+ /// Thrown when <paramref name="cell"/> or <paramref name="sheetData"/> is null.
25
+ /// </exception>
15
26
public Cell ( DocumentFormat . OpenXml . Spreadsheet . Cell cell , SheetData sheetData )
16
27
{
17
28
_cell = cell ?? throw new ArgumentNullException ( nameof ( cell ) ) ;
18
29
_sheetData = sheetData ?? throw new ArgumentNullException ( nameof ( sheetData ) ) ;
19
30
}
20
31
32
+ /// <summary>
33
+ /// Sets the value of the cell as a string.
34
+ /// </summary>
35
+ /// <param name="value">The value to set.</param>
21
36
public void PutValue ( string value )
22
37
{
23
38
PutValue ( value , CellValues . String ) ;
24
39
}
25
40
41
+ /// <summary>
42
+ /// Sets the value of the cell as a number.
43
+ /// </summary>
44
+ /// <param name="value">The numeric value to set.</param>
26
45
public void PutValue ( double value )
27
46
{
28
47
PutValue ( value . ToString ( CultureInfo . InvariantCulture ) , CellValues . Number ) ;
29
48
}
30
49
50
+ /// <summary>
51
+ /// Sets the value of the cell as a date.
52
+ /// </summary>
53
+ /// <param name="value">The date value to set.</param>
31
54
public void PutValue ( DateTime value )
32
55
{
33
56
PutValue ( value . ToOADate ( ) . ToString ( CultureInfo . InvariantCulture ) , CellValues . Date ) ;
34
57
}
35
58
59
+ /// <summary>
60
+ /// Sets the cell's value with a specific data type.
61
+ /// </summary>
62
+ /// <param name="value">The value to set.</param>
63
+ /// <param name="dataType">The data type of the value.</param>
36
64
private void PutValue ( string value , CellValues dataType )
37
65
{
38
66
_cell . DataType = new EnumValue < CellValues > ( dataType ) ;
39
67
_cell . CellValue = new CellValue ( value ) ;
40
68
41
69
}
42
70
71
+ /// <summary>
72
+ /// Sets a formula for the cell.
73
+ /// </summary>
74
+ /// <param name="formula">The formula to set.</param>
43
75
public void PutFormula ( string formula )
44
76
{
45
77
_cell . CellFormula = new CellFormula ( formula ) ;
46
78
_cell . CellValue = new CellValue ( ) ; // You might want to set some default value or calculated value here
47
79
}
48
80
81
+ /// <summary>
82
+ /// Gets the value of the cell.
83
+ /// </summary>
84
+ /// <returns>The cell value as a string.</returns>
49
85
public string GetValue ( )
50
86
{
51
87
return _cell . CellValue ? . Text ;
52
88
}
53
89
90
+ /// <summary>
91
+ /// Gets the data type of the cell's value.
92
+ /// </summary>
93
+ /// <returns>The cell's value data type, or null if not set.</returns>
54
94
public CellValues ? GetDataType ( )
55
95
{
56
96
return _cell . DataType ? . Value ;
57
97
}
58
98
59
-
60
99
100
+ /// <summary>
101
+ /// Gets the formula set for the cell.
102
+ /// </summary>
103
+ /// <returns>The cell's formula as a string, or null if not set.</returns>
61
104
public string GetFormula ( )
62
105
{
63
106
return _cell . CellFormula ? . Text ;
64
107
}
65
108
109
+ /// <summary>
110
+ /// Applies a style to the cell.
111
+ /// </summary>
112
+ /// <param name="styleIndex">The index of the style to apply.</param>
66
113
public void ApplyStyle ( uint styleIndex )
67
114
{
68
115
_cell . StyleIndex = styleIndex ;
0 commit comments