ExcelDocumentWriter 1.0.2
See the version list below for details.
dotnet add package ExcelDocumentWriter --version 1.0.2
NuGet\Install-Package ExcelDocumentWriter -Version 1.0.2
<PackageReference Include="ExcelDocumentWriter" Version="1.0.2" />
<PackageVersion Include="ExcelDocumentWriter" Version="1.0.2" />
<PackageReference Include="ExcelDocumentWriter" />
paket add ExcelDocumentWriter --version 1.0.2
#r "nuget: ExcelDocumentWriter, 1.0.2"
#:package ExcelDocumentWriter@1.0.2
#addin nuget:?package=ExcelDocumentWriter&version=1.0.2
#tool nuget:?package=ExcelDocumentWriter&version=1.0.2
EXAMPLE
The following code demonstrates how to use MiniExcel to generate an Excel file programmatically. <br> The file "Test.xlsx" will be automatically created and saved when the Dispose method is invoked. <br> This library is built on the Open XML SDK, so it works even without Microsoft Excel installed. Moreover, there are no restrictions unique to the Open XML SDK. <br> MiniExcel is a lightweight, meaning-driven Excel generator designed for clarity, performance, and independence from external dependencies.
Ver.1.0.1<br> Minor fixes, with target OS restrictions removed.
Ver.1.0.2<br> Removed unnecessary library references.
using HimClassLib9.ExcelDocumentWriter;
public void MatrixTest() {
using (ExcelWorkbook workBook = new(@"C:\Users\MyAccount\.....\Test.xlsx")) {
ExcelWorkSheet workSheet1 = workBook.AddWorksheet("Sheet01");
// If a sheet name is duplicated, it will be renamed to ensure it is unique.
ExcelWorkSheet workSheet2 = workBook.AddWorksheet("Sheet01");
this.HeaderDraw(workSheet1);
this.HeaderDraw(workSheet2);
this.SetFormula(workSheet1, true);
this.SetFormula(workSheet2, false);
this.SetBorder(workSheet1);
this.SetBorder(workSheet2);
} // The file is created and saved by the Dispose method.
}
private void HeaderDraw(ExcelWorkSheet workSheet) {
workSheet.SetFreezePane(1, 1);
workSheet.ColumnWidth(1, 10, 5.63D); // Set columns Width
workSheet.ShowGridLines = false; // Hide the gridlines
for (int idx = 1; idx < 10; idx++) {
workSheet.CellValue(idx, (uint)(idx + 1), 1); // Set a value in the cell
workSheet.CellValue(idx, 1, (uint)(idx + 1)); // Set a value in the cell
}
}
private void SetFormula(ExcelWorkSheet workSheet, bool mode) {
workSheet.MoveTopLeft(); // Reset to 'A1'
workSheet.MoveDown(); // Move to the beginning of the next line
workSheet.MoveRight(); // Move the cursor one cell to the right
for (uint row = 1; row < 10; row++) {
string rowAddress = ExcelBookSheetSupport.GetCellReference(1, row + 1);
for (uint col = 1; col < 10; col++) {
string colAddress = ExcelBookSheetSupport.GetCellReference(col + 1, 1);
if (mode) {
workSheet.CellFormula($"={colAddress}*{rowAddress}"); // Set a formula in the cell
} else {
workSheet.CellFormula($"={colAddress}+{rowAddress}"); // Set a formula in the cell
}
workSheet.MoveRight(); // Move the cursor one position to the right
}
workSheet.MoveDown(); // Move to the beginning of the next line
workSheet.MoveRight(); // Move the cursor one cell to the right
}
}
private void SetBorder(ExcelWorkSheet workSheet) {
workSheet.CellRangeFill(1, 2, 1, 10, "E2EFDA");
workSheet.CellRangeFill(2, 1, 10, 1, "E2EFDA");
workSheet.CellRangeFill(2, 2, 10, 10, "D9E1F2");
//workSheet.CellRangeBorder(2, 2, 10, 10, BorderType.MATRIX, BorderLineValues.Thin);
workSheet.CellRangeBorder("B2:J10", BorderType.MATRIX, BorderLineValues.Thin);
//workSheet.CellRangeBorder(2, 2, 10, 10, BorderType.OUTERBOX, BorderLineValues.Thick);
workSheet.CellRangeBorder("B2:J10", BorderType.OUTERBOX, BorderLineValues.Thick);
workSheet.CellRangeBorder(1, 2, 1, 10, BorderType.BOTTOM, BorderLineValues.Thin);
workSheet.CellRangeBorder(1, 2, 1, 10, BorderType.OUTERBOX, BorderLineValues.Thick);
workSheet.CellRangeBorder(2, 1, 10, 1, BorderType.LEFT, BorderLineValues.Thin);
workSheet.CellRangeBorder(2, 1, 10, 1, BorderType.OUTERBOX, BorderLineValues.Thick);
workSheet.CellRangeAlignment(1, 2, 1, 10, VerticalCellAlignment.Center, HorizontalCellAlignment.Center);
workSheet.CellRangeAlignment(2, 1, 10, 1, VerticalCellAlignment.Center, HorizontalCellAlignment.Center);
workSheet.CellRangeAlignment(2, 2, 10, 10, VerticalCellAlignment.Center, HorizontalCellAlignment.Center);
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- DocumentFormat.OpenXml (>= 3.3.0)
- DocumentFormat.OpenXml.Framework (>= 3.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.