YGMSExcelBeater 1.7.0

dotnet add package YGMSExcelBeater --version 1.7.0
                    
NuGet\Install-Package YGMSExcelBeater -Version 1.7.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="YGMSExcelBeater" Version="1.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YGMSExcelBeater" Version="1.7.0" />
                    
Directory.Packages.props
<PackageReference Include="YGMSExcelBeater" />
                    
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 YGMSExcelBeater --version 1.7.0
                    
#r "nuget: YGMSExcelBeater, 1.7.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.
#addin nuget:?package=YGMSExcelBeater&version=1.7.0
                    
Install YGMSExcelBeater as a Cake Addin
#tool nuget:?package=YGMSExcelBeater&version=1.7.0
                    
Install YGMSExcelBeater as a Cake Tool

README

What is this repository for?

This class libary uses NPOI to read and write to excel file with c# .net 6 and above. It has internal mapper to map the contents of Excel sheet to a generic collection List<T> as long as the property names match the field names in the excel file. The header row must be the first row and data must start from the first column, second row

How do I get set up?

The Excel file must have a header to hold the field names. The field names must not have spaces or special characters All field names must be reproducable in the DTO where the records are mapped to

Sample setup: (Excel containing a key field in column 0 "L-2" being one of the unique values )


// Sample.xlsx is provided in the source code - just an excel file containing RecordID, Name, Title, IsActive, and DOB

string excelFileName = "C:\\Temp\\Sample.xlsx";

// Constructor takes filename, sheet number, and column number for the key, or, column name
    using (IMSExcelBeater beater = new MSExcelBeater(excelFileName, 0, 0)) // first parm: filename, second parm: sheet number. Third parm: key column number or name
         {
             string[] fieldNames = beater.GetAllFieldNames(); // Use this function to retreve all field names and to construct the DTO

             List<TestDTO> allData = beater.GetAllData<TestDTO>(); // This is to retrieve the entire sheet into a generic collection of DTO (that could be created using .GetAllFieldNames())

             // This is to update the Excel file directly -----------------
             string title = beater.Get("L-2", "title"); // This is to get a value from column "title" row key number "L-2"
             string result1 = beater.Update("L-2", "title", "bloon"); // This is to update the value in column "title" row key number "L-2"
             string result2 = beater.Save(); // This is to save all the updates. Remember to invoke .Save() to save your changes.

         }

// Export DataSet to Excel:

    string outputFilePath = @"C:\Temp\FakeDataSetOutput.xlsx";

    // Export DataSet to Excel
    using (IMSExcelBeater exporter = new MSExcelBeater(outputFilePath))
    {
        exporter.ExportDataSetToExcel(fakeDataSet);
    }

    Console.WriteLine($"Excel file created successfully at: {outputFilePath}");

    using (IMSExcelBeater beater = new MSExcelBeater(excelFileName, 0, 0)) // first parm: filename, second parm: sheet number. Third parm: key column number or name
    {
    // Import Excel to DataTable 
    DataTable dt = beater.GetAllData();

    //Import Excel to a known DTO
    List<DTO> dtos = beater.GetAllData<DTO>(); 
    }

Contribution guidelines

  • Writing tests
  • Code review
  • Other guidelines

Who do I talk to?

  • Repo owner or admin
Product Compatible and additional computed target framework versions.
.NET 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 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.

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.7.0 134 5/23/2025
1.6.0 168 4/3/2025
1.5.0 125 3/27/2025
1.4.0 124 3/27/2025
1.3.0 106 2/20/2025
1.2.0 116 1/2/2025
1.1.0 100 12/21/2024
1.0.6 103 11/7/2024
1.0.5 102 10/24/2024
1.0.4 137 10/18/2024
1.0.3 141 10/18/2024
1.0.2 131 10/18/2024
1.0.1 130 10/18/2024

Handle missing first row in the constructor