SpreadSheetParser 0.0.7

dotnet add package SpreadSheetParser --version 0.0.7                
NuGet\Install-Package SpreadSheetParser -Version 0.0.7                
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="SpreadSheetParser" Version="0.0.7" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SpreadSheetParser --version 0.0.7                
#r "nuget: SpreadSheetParser, 0.0.7"                
#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.
// 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.

  1. Choose a .xlsx file:

Image Book.xlsx

  1. 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.

  1. In the constructor, you have to use the base method "TryBuildObject<YourClass>(this)", it will try to create a object using reflection.

  2. 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>();
  1. The result should be like this:

Image Book.xlsx

This component reads just one sheet per builder, if you want to read multiple sheet, use a builder to each one.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.0.7 468 6/19/2022
0.0.6 396 6/19/2022
0.0.5 393 6/19/2022
0.0.4 421 6/18/2022
0.0.3 394 6/18/2022
0.0.2 412 6/18/2022
0.0.1 421 6/18/2022