FakeExcelSerializer 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FakeExcelSerializer --version 1.1.0
                    
NuGet\Install-Package FakeExcelSerializer -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FakeExcelSerializer" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FakeExcelSerializer" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="FakeExcelSerializer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FakeExcelSerializer --version 1.1.0
                    
#r "nuget: FakeExcelSerializer, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FakeExcelSerializer@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FakeExcelSerializer&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=FakeExcelSerializer&version=1.1.0
                    
Install as a Cake Tool

FakeExcelSerializer

Convert object to Excel file (.xlsx) [Open XML SpreadsheetML File Format]

Getting Started

Supporting platform is .NET 6.

PM> Install-Package FakeExcelSerializer

Usage

You can use ExcelSerializer.ToFile.

ExcelSerializer.ToFile(Users, "test.xlsx", ExcelSerializerOptions.Default);

Notice

Folder creation permissions are required since a working folder will be used.

Benchmark

N = 100 lines.

Method N Mean Error StdDev Ratio Gen 0 Gen 1 Gen 2 Allocated
ClosedXml 1 36.078 ms 0.3324 ms 0.3109 ms 1.00 857.1429 357.1429 - 5,734 KB
FakeExcelSerializer 1 4.587 ms 0.0397 ms 0.0332 ms 0.13 15.6250 7.8125 - 127 KB
ClosedXml 10 343.416 ms 5.7000 ms 4.7598 ms 1.00 8000.0000 1000.0000 - 52,661 KB
FakeExcelSerializer 10 9.067 ms 0.0850 ms 0.0709 ms 0.03 93.7500 31.2500 - 661 KB
ClosedXml 100 3,663.531 ms 23.3744 ms 20.7208 ms 1.00 81000.0000 22000.0000 5000.0000 513,936 KB
FakeExcelSerializer 100 47.989 ms 0.9378 ms 0.8773 ms 0.01 909.0909 90.9091 - 6,005 KB

Examples

If you pass an object, it will be converted to an Excel file.

ExcelSerializer.ToFile(new string[] { "test", "test2" }, @"c:\test\test.xlsx", ExcelSerializerOptions.Default);

image

Passing a class expands the property into a column.

public class Portal
{
    public string Name { get; set; }
    public string Owner { get; set; }
    public int Level { get; set; }
}

var potals = new Portal[] {
    new Portal { Name = "Portal1", Owner = "panda728", Level = 8 },
    new Portal { Name = "Portal2", Owner = "panda728", Level = 1 },
    new Portal { Name = "Portal3", Owner = "panda728", Level = 2 },
};

ExcelSerializer.ToFile(potals, @"c:\test\potals.xlsx", ExcelSerializerOptions.Default);

image

Options can be set to display a title line and automatically adjust column widths.

var newConfig = ExcelSerializerOptions.Default with
{
    CultureInfo = CultureInfo.InvariantCulture,
    HasHeaderRecord = true,
    HeaderTitles = new string[] { "Name", "Owner", "Level" },
    AutoFitColumns = true,
};
ExcelSerializer.ToFile(potals, @"c:\test\potalsOp.xlsx", newConfig);

image

Note

For the method of retrieving values from IEnumerable<T>, Cysharp's WebSerializer method is used.

https://github.com/Cysharp/WebSerializer

The following page provides information on how to return to OpenOfficeXml.

https://gist.github.com/iso2022jp/721df3095f4df512bfe2327503ea1119

https://docs.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/2c5dee00-eff2-4b22-92b6-0738acd4475## Benckma

Sample Extensions

WindowsForm's DataGridView to .xlsx

https://github.com/panda728/DataGridViewDump

CSV-like File output version https://github.com/panda728/FakeCsvSerializer

License

This library is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

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
1.3.4 259 7/11/2023
1.3.3 302 2/25/2023
1.3.2 483 8/31/2022
1.3.1 430 8/30/2022
1.3.0 415 8/30/2022
1.2.1 426 8/29/2022
1.2.0 417 8/28/2022
1.1.0 424 8/26/2022
1.0.3 416 8/23/2022
1.0.2 397 8/22/2022
1.0.1 423 8/21/2022
1.0.0 419 8/20/2022
0.2.0 434 8/20/2022
0.1.0 426 8/19/2022