BigExcelCreator 3.4.2026.10623
dotnet add package BigExcelCreator --version 3.4.2026.10623
NuGet\Install-Package BigExcelCreator -Version 3.4.2026.10623
<PackageReference Include="BigExcelCreator" Version="3.4.2026.10623" />
<PackageVersion Include="BigExcelCreator" Version="3.4.2026.10623" />
<PackageReference Include="BigExcelCreator" />
paket add BigExcelCreator --version 3.4.2026.10623
#r "nuget: BigExcelCreator, 3.4.2026.10623"
#:package BigExcelCreator@3.4.2026.10623
#addin nuget:?package=BigExcelCreator&version=3.4.2026.10623
#tool nuget:?package=BigExcelCreator&version=3.4.2026.10623
Big Excel Creator
Create Excel files using OpenXML SAX with styling. This is specially useful when trying to output thousands of rows.
The idea behind this package is to be a basic easy-to-use wrapper around a reduced subset of functions of DocumentFormat.OpenXml aimed towards generating large excel files as fast as possible using the SAX method for writing.
At the same time, this writer should prevent you from creating an invalid file (i.e.: a file generated without any errors, but unable to be opened). Since the most common reason for a file to become corrupted when creating it using SAX is out-of-order instructions (i.e.: writing to a cell outside a sheet), this package should detect that, and throw an exception.
| More info | API |
|---|
NOTE
Version 2.x of this package is linked to version 2.20.0 of DocumentFormat.OpenXml, and starting on version 3, BigExcelCreator is linked to version 3 of DocumentFormat.OpenXml.
Version 2.3.x is maintained as legacy. New features might be included, but not guaranteed. Testing is limited. I recommend using version 3.x if possible.
If you're already using DocumentFormat.OpenXml v2, either directly or as transitive reference, and you can't upgrade for some reason (e.g. dependency on another package), use BigExcelCreator v2
Otherwise, I recommend using the latest version available.
Table of Contents
Usage
To see a working example, see the example code on gitHub, part of the vs solution.
Instantiate class
BigExcelWriterusing either a file path or a stream (MemoryStreamis recommended).Open a new Sheet using
CreateAndOpenSheetFor every row, use
BeginRowandEndRow- If you want to hide a row, pass
truewhen callingBeginRow
- If you want to hide a row, pass
Between
BeginRowandEndRow, useWriteTextCellto write a cell.Alternatively, you can use
WriteTextRowto write an entire row at once, using the same format.Text cells can be written using the shared strings table, which can reduce the generated file size. See Shared Strings below.
If you are exporting a collection of objects, use
CreateSheetFromObject. See Creating sheets from objects for object-based export and configuration.See more in the example code and in the API documentation
Use
WriteFormulaCellorWriteFormulaRowto insert formulas.Use
WriteNumberCellorWriteNumberRowto insert numbers. This is useful if you need to do any calculation later on.Use
CloseSheetto finish.If needed, repeat steps 2 → 5 to write to another sheet
Shared Strings
If the same text appears across different sheets, using the shared strings table may help reduce the generated file size.
In order to do this, simply set to true the useSharedStrings parameter when calling WriteTextCell or WriteTextRow.
If you use object export with CreateSheetFromObject, enable useSharedStringsOnTextData for the same shared-string optimization. See Creating sheets from objects.
Creating sheets from objects
Use CreateSheetFromObject to write an entire sheet from a collection of objects.
This method maps object properties to sheet columns and applies attribute-based configuration for headers, styles, and conditional formatting.
using BigExcelCreator;
using BigExcelCreator.ClassAttributes;
[ExcelHeaderStyleFormat("HeaderStyle")]
public class Product
{
[ExcelColumnOrder(0)]
[ExcelColumnName("Product Id")]
[ExcelColumnType(CellDataType.Number)]
[ExcelColumnWidth(10)]
public int Id { get; set; }
[ExcelColumnOrder(1)]
[ExcelColumnName("Product Name")]
[ExcelColumnType(CellDataType.Text)]
[ExcelColumnWidth(25)]
public string Name { get; set; } = string.Empty;
}
....
MemoryStream stream = new MemoryStream();
using (BigExcelWriter excel = new(stream))
{
var data = new List<Product>
{
new() { Id = 1, Name = "Product A" },
new() { Id = 2, Name = "Product B" }
};
excel.CreateSheetFromObject(data, "Products");
excel.CloseSheet();
}
Available attributes for configuration:
ExcelIgnore: Exclude property from outputExcelColumnName: Custom column headerExcelColumnOrder: Column position (0-based)ExcelColumnType: Cell data type mappingExcelColumnWidth: Column width in charactersExcelColumnHidden: Hide column from viewExcelStyleFormat: Style for data cellsExcelHeaderStyleFormat: Style for header rowExcelConditionalFormatFormula: Formula-based conditional formattingExcelConditionalFormatCellIs: Value-based conditional formattingExcelConditionalFormatDuplicatedValues: Highlight duplicates
See the API documentation for more details.
Example
using BigExcelCreator;
....
MemoryStream stream = new MemoryStream();
using (BigExcelWriter excel = new(stream))
{
excel.CreateAndOpenSheet("Sheet Name");
excel.BeginRow();
excel.WriteTextCell("Cell content");
excel.WriteTextCell(123); // write as number. This allows to use formulas.
excel.WriteTextCell(456);
excel.WriteFormulaCell("SUM(B1:C1)");
excel.EndRow();
excel.BeginRow(true);
excel.WriteTextCell("This row is hidden");
excel.EndRow();
excel.CloseSheet();
}
Data Validation
Use AddListValidator to restrict, to a list defined in a formula,
possible values to be written to a cell by an user.
If you are exporting objects with CreateSheetFromObject, use conditional formatting attributes on properties instead of per-cell validation. See Creating sheets from objects.
Alternatively, use AddIntegerValidator or AddDecimalValidator to restrict / validate values
as defined by validationType (equal, greater than, between, etc.)
excel.CreateAndOpenSheet("Sheet Name");
...
// Only allow values included in sheet named "vals" between cells A1 and A6
// when writing to cells between B2 and B10 of the current sheet.
string range = "B2:B10";
string formula = "vals!$A$1:$A$6";
excel.AddValidator(range, formula);
excel.CloseSheet();
Styling and formatting
Column formatting
When calling CreateAndOpenSheet, pass IList<Column> as second parameter.
Each element represents a single column.
Only the CustomWidth, Width and Hidden are used.
When using CreateSheetFromObject, styling and conditional formatting can be configured on object properties using attributes. See Creating sheets from objects.
Width represents the column width in characters (Same unit as when resizing in Excel).
CustomWidth allows the use of Width.
Hidden hides the column.
Example
List<Column> cols = new List<Column> {
new Column{CustomWidth = true, Width=10}, // A
new Column{CustomWidth = true, Width=15}, // B
new Column{CustomWidth = true, Width=18}, // c
};
excel.CreateAndOpenSheet("Sheet Name", cols);
Hide Sheet
CreateAndOpenSheet accepts as third parameter a SheetStateValues variable.
SheetStateValues.Visible(default): Sheet is visibleSheetStateValues.Hidden: Sheet is hiddenSheetStateValues.VeryHidden: Sheet is hidden and cannot be unhidden from Excel's UI.
When exporting collections with CreateSheetFromObject, you can also control sheet visibility using the same SheetStateValues parameter. See Creating sheets from objects.
Merge Cells
In order to merge a range of cells while a sheet is open, use MergeCells with a range.
excel.MergeCells("A1:A5");
Styling
First, the elements that define a style (font, fill, border and, optionally, numbering format) must be created.
font1 = new Font(new Bold(),
new FontSize { Val = 11 },
new Color { Rgb = new HexBinaryValue { Value = "000000" } },
new FontName { Val = "Calibri" });
fill1 = new Fill(
new PatternFill { PatternType = PatternValues.Gray125 });
fill2 = new Fill(
new PatternFill (
new ForegroundColor { Rgb = new HexBinaryValue { Value = "FFFF00" } }
)
{ PatternType = PatternValues.Solid });
border1 = new Border(
new LeftBorder(
new Color { Rgb = new HexBinaryValue { Value = "FFD3D3D3" } }
)
{ Style = BorderStyleValues.Thin },
new RightBorder(
new Color { Rgb = new HexBinaryValue { Value = "FFD3D3D3" } }
)
{ Style = BorderStyleValues.Thin },
new TopBorder(
new Color { Rgb = new HexBinaryValue { Value = "FFD3D3D3" } }
)
{ Style = BorderStyleValues.Thin },
new BottomBorder(
new Color { Rgb = new HexBinaryValue { Value = "FFD3D3D3" } }
)
{ Style = BorderStyleValues.Thin },
new DiagonalBorder());
numberingFormat1 = new NumberingFormat { NumberFormatId = 164, FormatCode = "0,.00;(0,.00)" };
After that, a new style list can be created and new styles inserted. Remember to name you styles.
StyleList list = new StyleList();
string name1 = "name1";
string name2 = "name2";
list.NewStyle(font1, fill1, border1, numberingFormat1, name1);
list.NewStyle(font1, fill2, border1, numberingFormat1, name2);
When instantiating BigExcelWriter, use the result of calling GetStylesheet as the stylesheet parameter.
Then, when writing a cell, you can use the name given earlier to format it.
MemoryStream stream = new MemoryStream();
using (BigExcelWriter excel = new(stream,
DocumentFormat.OpenXml.SpreadsheetDocumentType.Workbook
stylesheet: list.GetStylesheet()))
{
int index_style_name1 = list.GetIndexByName(name1);
int index_style_name2 = list.GetIndexByName(name2);
excel.CreateAndOpenSheet("Sheet Name");
excel.BeginRow();
excel.WriteTextCell("This has a gray patterned background", index_style_name1);
excel.WriteTextCell("This has a yellow background", index_style_name2);
excel.EndRow();
excel.CloseSheet();
}
If you're planning to use Conditional Formatting, you must also create differential styles here. To do so, follow the same instructions as above, replacing
NewStylewithNewDifferentialStyle.All parameters of
NewDifferentialStyleare optional, exceptname. Of the optional parameters, at least one must be present.
// place this before calling list.GetStylesheet() and new BigExcelWriter()
list.NewDifferentialStyle("RED", font: new Font(new Color { Rgb = new HexBinaryValue { Value = "FF0000" } }));
Comments
In order to add a note (formerly known as comment) to a cell, while a sheet is open, call the Comment method.
excel.CreateAndOpenSheet("Sheet Name");
excel.BeginRow();
excel.WriteTextCell("This has a gray patterned background", index_style_name1);
excel.WriteTextCell("This has a yellow background", index_style_name2);
excel.Comment("test A1 another sheet", "A1");
excel.EndRow();
excel.Comment("test E2 another sheet", "B1", "Author");
excel.CloseSheet();
Autofilter
In order to add an Autofilter, call AddAutofilter while on a sheet.
excel.BeginRow();
// ...
excel.AddAutofilter(range); // Range's height must be 1. Example: A1:J1
// ...
excel.EndRow();
Conditional Formatting
In order to use conditional formatting, you should define Differential styles (see Styling)
On every case below:
reference⇒ A range of cells to apply the conditional formatting toformat⇒ The id of the Differential style. Obtain it usingGetIndexDifferentialByNameafter creating it withNewDifferentialStyle
Formula
To define a conditional style by formula, use AddConditionalFormattingFormula(string reference, string formula, int format).
formuladefines the expression to use. Use a fixed range using$to anchor the reference to a cell. Avoid using$to make the reference "walk" with the range. This is useful when referencing the current cell.
excel.AddConditionalFormattingFormula("A1:A10", "A1<5", styleList.GetIndexDifferentialByName("RED"));
Cell Is
Format cells based on their contents using AddConditionalFormattingCellIs
Operatordefines how to compare values.valuedefines the value to compare the cell to.value2If the operator requires 2 numbers (eg:BetweenandNotBetween), the second value goes here.
excel.AddConditionalFormattingCellIs("A1:A20", ConditionalFormattingOperatorValues.LessThan, "5", styleList.GetIndexDifferentialByName("RED"));
excel.AddConditionalFormattingCellIs("A1:A20", ConditionalFormattingOperatorValues.Between, "3", styleList.GetIndexDifferentialByName("RED"), "7");
Duplicated Values
Format duplicated values using AddConditionalFormattingDuplicatedValues
excel.AddConditionalFormattingDuplicatedValues("A1:A10", styleList.GetIndexDifferentialByName("RED"));
Page Layout
Sheet options
Gridlines
While working on a sheet, the property ShowGridLinesInCurrentSheet controls whether the gridlines are shown.
Enabled by default.
While working on a sheet, the property PrintGridLinesInCurrentSheet controls whether the gridlines are printed.
Disabled by default.
Headings
While working on a sheet, the property ShowRowAndColumnHeadingsInCurrentSheet controls whether the headings (Column letters and row numbers) are shown.
Enabled by default.
While working on a sheet, the property PrintRowAndColumnHeadingsInCurrentSheet controls whether the headings (Column letters and row numbers) are printed.
Disabled by default.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
-
.NETFramework 4.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
-
.NETFramework 4.6
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
-
.NETFramework 4.8
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
-
.NETStandard 2.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
-
net10.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
-
net8.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 3.4.2026.10623 | 844 | 4/16/2026 | |
| 3.3.2025.35601 | 727 | 12/22/2025 | |
| 3.2.2024.32600 | 331 | 11/21/2024 | |
| 3.1.2024.30215 | 185 | 10/28/2024 | |
| 3.0.2024.12304 | 207 | 5/2/2024 | |
| 2.3.2026.10623 | 99 | 4/16/2026 | |
| 2.3.2025.35601 | 202 | 12/22/2025 | |
| 2.3.2024.32600 | 173 | 11/21/2024 | |
| 2.3.2024.30215 | 189 | 10/28/2024 | |
| 2.3.2023.24606 | 283 | 9/3/2023 | |
| 2.2.2022.32620 | 2,322 | 11/22/2022 | |
| 2.2.2022.32316 | 491 | 11/19/2022 | |
| 2.1.2022.31704 | 556 | 11/13/2022 | |
| 2.1.2022.30921-alpha | 361 | 11/5/2022 |
# Changelog
## 3.4
### Added
- Ability to reference styles by name when writing cells. This is achieved by passing a `StyleList` instance when creating the `BigExcelWriter` instead of a `StyleSheet` instance.
- Ability to format the output when writing from a list of objects of a custom class, configuring which properties to write and how to format them using attributes.
## 3.3 (and 2.3.2025.35601)
### Added
- Support to write a new sheet directly from a list of objects of a custom class, configuring which properties to write using attributes.
- .Net10.0 build target
### Removed
- .NetStandard1.3 build target (from version 2.3.x) since it's EOL.
## 3.2 (and 2.3.2024.32600)
### Added
- Throw exceptions when attempting to create a sheet with an invalid name.
- Throw exceptions when attempting to create a sheet with the same name as an existing sheet.
### Changed
- It's no longer mandatory to provide a SpreadsheetDocumentType when creating a new BigExcelWriter. The default value is now Workbook (.xlsx).
- Improved documentation comments. Also published in https://fenase.github.io/BigExcelCreator/api/BigExcelCreator.html
## 3.1 (and 2.3.2024.30215)
### Added
- Overloads for WriteNumberCell and WriteNumberRow to accept different numeric types in addition to float.
## 3.0
This version uses the new 3.* version of DocumentFormat.OpenXml and it's not compatible with 2.*
If you're using another package that require DocumentFormat.OpenXml 2.*, consider using version 2.3 of this package.
### Added
- .Net8.0 build target
### Removed
- .NetStandard1.3 build target
## 2.3
### Removed
- Finally removed method AddValidator (marked as obsolete since before version 1)
### Added
- Integer and decimal data validation
- .Net6.0 build target
### Changed
- Throwing more specific exceptions instead of just throwing InvalidOperacionException for everything
- Dependency update: DocumentFormat.OpenXml 2.18.0 -> 2.20.0
## 2.2
### Added
- Show or hide, print or not, Gridlines and headings
### Changed
- Bumped dependencies version to current latest since the reason to lower it no longer applies.
## 2.1
### Changed
- Lowered minimum required version of DocumentFormat.OpenXml. It is still recommended to use the latest version when possible.
### Added
- Ability to merge cells
## 2.0
### Changed
- Renamed class BigExcelWritter to BigExcelWriter.
Sorry for the typo.
### Added
- Conditional formatting
- By formula
- By value (Cell Is)
- Duplicated values
## 1.1
### Added
- Text cells can now be written as shared strings instead of as value. This should reduce the final file's size when the same text is repeated across sheets
## 1.0
- First version considered to be "stable".
- Moved repository to GitHub (previously hosted on Azure DevOps)
### Changed
- Renamed `WriteTextCell<int>` to `WriteNumberCell<int>`. `WriteTextCell<string>` is still in use.
## 1.0.265
### Added
- Hide rows and columns
- Write formula to cell
## 0.2022.262
### Added
- Create autofilter
- Ranges are now validated
## 0.2022.261
### Added
- Add comments to cells
## 0.2022.256
### Added
- Styling and formatting
## 0.2022.253
- Initial version