SpreadSheetParser 0.0.7
dotnet add package SpreadSheetParser --version 0.0.7
NuGet\Install-Package SpreadSheetParser -Version 0.0.7
<PackageReference Include="SpreadSheetParser" Version="0.0.7" />
paket add SpreadSheetParser --version 0.0.7
#r "nuget: SpreadSheetParser, 0.0.7"
// Install SpreadSheetParser as a Cake Addin #addin nuget:?package=SpreadSheetParser&version=0.0.7 // Install SpreadSheetParser as a Cake Tool #tool nuget:?package=SpreadSheetParser&version=0.0.7
SpreadSheetParser
Convert your .xlsx file to a C# object and them, do what you want!
This package can help read and parse a SpreadSheet/Excel .xlsx file and return a object.
- Choose a .xlsx file:
- Make a class to represent this sheet
[DisplayName("First Sheet")]
public class SampleSheet : SheetObject
{
[DisplayName("First Column")]
public Double FirstColumn { get; set; }
[DisplayName("Second Column")]
public Double SecondColumn { get; set; }
public SampleSheet(SheetHeader header, SheetRow row) : base(header, row)
{
if (TryBuildObject<SampleSheet>(this) is false)
throw new ArgumentException("Could not create a sample object");
}
}
Pay attention to the DisplayNameAttribute, we are using this to infer the sheet name and the table header columns name.
Make sure the type of the properties is exactly the same of the spread sheet column.
The first row in the sheet is used as a Header, each column must always be a string in this row.
In the constructor, you have to use the base method "TryBuildObject<YourClass>(this)", it will try to create a object using reflection.
Now, you can create a SheetFile<YourClass>:
using SpreadSheetParser.Models;
using SpreadSheetParser.Extensions;
var sheet = new SheetFile<SampleSheet>(new FileInfo("Book.xlsx"));
List<SampleSheet> sampleObjects = sheet.BuildSheet<SampleSheet>();
- The result should be like this:
This component reads just one sheet per builder, if you want to read multiple sheet, use a builder to each one.
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
- ExcelDataReader (>= 3.6.0)
- System.Text.Encoding.CodePages (>= 6.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.