Skip to content

Commit 0ee6ff2

Browse files
author
Fahad Adeel
committed
Commented the Code for Api References and added a sample of programs.
1 parent 913a41f commit 0ee6ff2

File tree

5 files changed

+561
-145
lines changed

5 files changed

+561
-145
lines changed

FileFormat.Cells/Cell.cs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,106 @@ public sealed class Cell
1010
private readonly DocumentFormat.OpenXml.Spreadsheet.Cell _cell;
1111
private readonly SheetData _sheetData;
1212

13+
/// <summary>
14+
/// Gets the cell reference in A1 notation.
15+
/// </summary>
1316
public string CellReference => _cell.CellReference;
1417

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>
1526
public Cell(DocumentFormat.OpenXml.Spreadsheet.Cell cell, SheetData sheetData)
1627
{
1728
_cell = cell ?? throw new ArgumentNullException(nameof(cell));
1829
_sheetData = sheetData ?? throw new ArgumentNullException(nameof(sheetData));
1930
}
2031

32+
/// <summary>
33+
/// Sets the value of the cell as a string.
34+
/// </summary>
35+
/// <param name="value">The value to set.</param>
2136
public void PutValue(string value)
2237
{
2338
PutValue(value, CellValues.String);
2439
}
2540

41+
/// <summary>
42+
/// Sets the value of the cell as a number.
43+
/// </summary>
44+
/// <param name="value">The numeric value to set.</param>
2645
public void PutValue(double value)
2746
{
2847
PutValue(value.ToString(CultureInfo.InvariantCulture), CellValues.Number);
2948
}
3049

50+
/// <summary>
51+
/// Sets the value of the cell as a date.
52+
/// </summary>
53+
/// <param name="value">The date value to set.</param>
3154
public void PutValue(DateTime value)
3255
{
3356
PutValue(value.ToOADate().ToString(CultureInfo.InvariantCulture), CellValues.Date);
3457
}
3558

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>
3664
private void PutValue(string value, CellValues dataType)
3765
{
3866
_cell.DataType = new EnumValue<CellValues>(dataType);
3967
_cell.CellValue = new CellValue(value);
4068

4169
}
4270

71+
/// <summary>
72+
/// Sets a formula for the cell.
73+
/// </summary>
74+
/// <param name="formula">The formula to set.</param>
4375
public void PutFormula(string formula)
4476
{
4577
_cell.CellFormula = new CellFormula(formula);
4678
_cell.CellValue = new CellValue(); // You might want to set some default value or calculated value here
4779
}
4880

81+
/// <summary>
82+
/// Gets the value of the cell.
83+
/// </summary>
84+
/// <returns>The cell value as a string.</returns>
4985
public string GetValue()
5086
{
5187
return _cell.CellValue?.Text;
5288
}
5389

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>
5494
public CellValues? GetDataType()
5595
{
5696
return _cell.DataType?.Value;
5797
}
5898

59-
6099

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>
61104
public string GetFormula()
62105
{
63106
return _cell.CellFormula?.Text;
64107
}
65108

109+
/// <summary>
110+
/// Applies a style to the cell.
111+
/// </summary>
112+
/// <param name="styleIndex">The index of the style to apply.</param>
66113
public void ApplyStyle(uint styleIndex)
67114
{
68115
_cell.StyleIndex = styleIndex;

FileFormat.Cells/Image.cs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,35 @@
99

1010
namespace FileFormat.Cells
1111
{
12-
1312

14-
13+
/// <summary>
14+
/// Represents an image, providing methods and properties to handle its path, data, and extension.
15+
/// </summary>
1516
public class Image
1617
{
18+
/// <summary>
19+
/// Gets the path of the image if initialized using a file path.
20+
/// </summary>
1721
public string Path { get; }
22+
23+
/// <summary>
24+
/// Gets the stream data of the image if initialized using a stream.
25+
/// </summary>
1826
public Stream Data { get; }
19-
public string Extension { get; }
2027

28+
/// <summary>
29+
/// Gets the file extension of the image.
30+
/// </summary>
31+
public string Extension { get; }
2132

22-
// You can add more properties as needed, such as format, size, etc.
2333

34+
/// <summary>
35+
/// Initializes a new instance of the <see cref="Image"/> class using a file path.
36+
/// </summary>
37+
/// <param name="path">The path to the image file.</param>
38+
/// <exception cref="ArgumentException">
39+
/// Thrown when <paramref name="path"/> is null or empty or when the file does not exist.
40+
/// </exception>
2441
public Image(string path)
2542
{
2643
if (string.IsNullOrEmpty(path) || !File.Exists(path))
@@ -30,7 +47,14 @@ public Image(string path)
3047
Extension = System.IO.Path.GetExtension(path);
3148
}
3249

33-
// Constructor to handle images that originate from streams
50+
/// <summary>
51+
/// Initializes a new instance of the <see cref="Image"/> class using a stream and a file extension.
52+
/// </summary>
53+
/// <param name="data">The stream containing the image data.</param>
54+
/// <param name="extension">The file extension of the image.</param>
55+
/// <exception cref="ArgumentNullException">
56+
/// Thrown when <paramref name="data"/> or <paramref name="extension"/> is null.
57+
/// </exception>
3458
public Image(Stream data, string extension)
3559
{
3660
Data = data ?? throw new ArgumentNullException(nameof(data));

0 commit comments

Comments
 (0)