SimpleExcelExporter 1.1.0
See the version list below for details.
dotnet add package SimpleExcelExporter --version 1.1.0
NuGet\Install-Package SimpleExcelExporter -Version 1.1.0
<PackageReference Include="SimpleExcelExporter" Version="1.1.0" />
paket add SimpleExcelExporter --version 1.1.0
#r "nuget: SimpleExcelExporter, 1.1.0"
// Install SimpleExcelExporter as a Cake Addin #addin nuget:?package=SimpleExcelExporter&version=1.1.0 // Install SimpleExcelExporter as a Cake Tool #tool nuget:?package=SimpleExcelExporter&version=1.1.0
SimpleExcelExporter
This C# library is intended to help export data to Excel .xlsx file.
Internally it uses the Microsoft DocumentFormat.OpenXml library. Unlike DocumentFormat.OpenXml, this library doesn't aim to produce any possible kind of .xlsx file but focus on the use case where a user of your application wants to export data to an Excel file. Of course you can use DocumentFormat.OpenXml directly but we believe this library is simpler and is less error prone for that particular use case.
How to use?
- Annotate your classes. Let's say you have a Player class in your code. Add annotations to guide SimpleExcelExporter how to export your data.
public class Player
{
[CellDefinition(CellDataType.Date)]
[Header(typeof(PlayerRes), "DateOfBirthColumnName")]
[Index(2)]
public DateTime? DateOfBirth { get; set; }
[CellDefinition(CellDataType.String)]
[Header(typeof(PlayerRes), "PlayerNameColumnName")]
[Index(1)]
public string? PlayerName { get; set; }
[CellDefinition(CellDataType.Number)]
[Header(typeof(PlayerRes), "NumberOfVictoryColumnName")]
[Index(3)]
public int? NumberOfVictory { get; set; }
[CellDefinition(CellDataType.Boolean)]
[Header(typeof(PlayerRes), "IsActiveFlagColumnName")]
[Index(4)]
public bool? IsActiveFlag { get; set; }
[CellDefinition(CellDataType.Boolean)]
[Header(typeof(PlayerRes), "SizeColumnName")]
[Index(5)]
public double? Size { get; set; }
[CellDefinition(CellDataType.Number)]
[Header(typeof(PlayerRes), "SalaryColumnName")]
[Index(5)]
public decimal? Salary { get; set; }
}
- Use SimpleExcelExporter to generate an Excel file:
using var memoryStream = new MemoryStream();
using var streamWriter = new StreamWriter(memoryStream);
var team = new Team
{
Players =
{
new Player
{
PlayerCode = "01",
PlayerName = "Alexandre",
Size = 1.93d,
DateOfBirth = new DateTime(1974, 02, 01),
IsActiveFlag = true,
NumberOfVictory = 45,
Salary = 2000.50m,
},
new Player
{
PlayerCode = "02",
PlayerName = "Elina",
Size = 1.72d,
DateOfBirth = new DateTime(1990, 10, 13),
IsActiveFlag = true,
NumberOfVictory = 52,
Salary = 2141.25m,
}
},
};
SpreadsheetWriter spreadsheetWriter = new SpreadsheetWriter(streamWriter.BaseStream, team);
spreadsheetWriter.Write();
using FileStream file = new FileStream(Path.Combine(tempDi.FullName, "TestWithData2.xlsx"), FileMode.Create, FileAccess.Write);
memoryStream.WriteTo(file);
What if I don't want to annotate my class with your annotations?
You can still use SimpleExcelExporter but you'll have a bit more code to write. Have a look at this example
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 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- DocumentFormat.OpenXml (>= 2.14.0)
- Microsoft.CSharp (>= 4.7.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 |
---|---|---|
1.4.3 | 68 | 9/23/2024 |
1.4.3-alpha | 55 | 9/23/2024 |
1.4.2 | 98 | 8/27/2024 |
1.4.2-alpha.1 | 49 | 8/27/2024 |
1.4.2-alpha | 102 | 8/21/2024 |
1.4.1 | 106 | 6/7/2024 |
1.4.1-alpha.2 | 49 | 6/7/2024 |
1.4.1-alpha.1 | 55 | 6/6/2024 |
1.4.1-alpha | 89 | 6/6/2024 |
1.4.0 | 357 | 6/3/2024 |
1.4.0-alpha | 88 | 6/3/2024 |
1.3.1 | 209 | 8/29/2023 |
1.3.0 | 182 | 8/28/2023 |
1.2.3 | 261 | 3/9/2023 |
1.2.2 | 253 | 3/8/2023 |
1.2.1 | 242 | 3/8/2023 |
1.1.0 | 425 | 2/20/2022 |