DataJuggler.Excelerate
7.0.12
See the version list below for details.
dotnet add package DataJuggler.Excelerate --version 7.0.12
NuGet\Install-Package DataJuggler.Excelerate -Version 7.0.12
<PackageReference Include="DataJuggler.Excelerate" Version="7.0.12" />
paket add DataJuggler.Excelerate --version 7.0.12
#r "nuget: DataJuggler.Excelerate, 7.0.12"
// Install DataJuggler.Excelerate as a Cake Addin #addin nuget:?package=DataJuggler.Excelerate&version=7.0.12 // Install DataJuggler.Excelerate as a Cake Tool #tool nuget:?package=DataJuggler.Excelerate&version=7.0.12
<img height=192 width=192 src=https://github.com/DataJuggler/Blazor.Excelerate/blob/main/wwwroot/Images/ExcelerateLogoSmallWhite.png>
Live Demo
Blazor.Excelerate https://excelerate.datajuggler.com Code Generate C# Classes From Excel Header Rows
DataJuggler.Excelerate
Update 11.9.2022 - 11.10.2022:
I added some new properties and enumerations for editing data in the Grid in DataJuggler.Blazor.Components.
Update 11.8.2022:
I added some new properties to the row and Column object for use with the Grid for DataJuggler.Blazor.Components.
Update 10.31.2022:
LoadWorksheetInfo.ExcludedColumnIndexes was added. This is a collection of integers to not load. I may expand this to column names also as an option.
--
Excelerate uses EPPPlus version 4.5.3.3 (last free version), and it makes it easy to load Workbooks or Worksheets.
A class named CodeGenerator was just created, and now by inheriting from the same CSharpClassWriter that code generates for DataTier.Net, I code generate classes based on your header row.
I have a couple of clients that I build programs that automate combining columns from multiple Worksheets to form reports.
Rather than continue to write custom loaders, I really only need custom Exporters in most cases.
Here is a short video: https://youtu.be/Sa-xroxPw_I
This short code snippet will load all the rows from a worksheet:
Snippet is from a Windows Form .Net 6 project, located in the Sample folder of this project. Very simple for now:
Load Worksheet Sample
using DataJuggler.UltimateHelper;
using DataJuggler.Excelerate;
using System;
using System.Windows.Forms;
// Set the text
string path = WorksheetControl.Text;
// Create a new instance of a 'LoadWorksheetInfo' object.
LoadWorksheetInfo loadWorksheetInfo = new LoadWorksheetInfo();
// Set the SheetName
oadWorksheetInfo.SheetName = SheetnameControl.SelectedObject.ToString();
// Only load the first 12 columns for this test
loadWorksheetInfo.ColumnsToLoad = 12;
// Set the LoadColumnOptions
loadWorksheetInfo.LoadColumnOptions = LoadColumnOptionsEnum.LoadFirstXColumns;
// other options
// loadWorksheetInfo.LoadColumnOptions = LoadColumnOptionsEnum.LoadAllColumnsExceptExcluded;
// loadWorksheetInfo.LoadColumnOptions = LoadColumnOptionsEnum.LoadSpecifiedColumns;
// load the worksheet
Worksheet worksheet = ExcelDataLoader.LoadWorksheet(path, loadWorksheetInfo);
// if the worksheet exists
if ((NullHelper.Exists(worksheet)) && (SheetnameControl.HasSelectedObject))
{
// if the rows collection was found
if (worksheet.HasRows)
{
// Show a message as a test
// MessageBox.Show("Worksheet Loaded", "Finished");
// test only
// int rows = worksheet.Rows.Count;
// Show a message as a test
// MessageBox.Show("There were " + String.Format("{0:n0}", rows) + " rows found in the worksheet");
// int cols = worksheet.Rows[1124].Columns.Count;
// Show a message as a test
// MessageBox.Show("There were " + String.Format("{0:n0}", cols) + " columns found in the row index 1125.");
// Get a nullable date
// string columnValue = worksheet.Rows[1124].Columns[3].DateValue;
// Show a message of the columnValue
// MessageBox.Show("Column Value: " + columnValue);
}
}
There is now a Code Generator class built into this project, to code generate a C# class from a header row.
The Code Generator has been updated to pass in a Row instance, to make loading the generate classes simple.
This code is from a Windows Form .Net 5 project located in the sample:
# Code Generation Sample
// if the value for HasWorksheet is true
if ((HasWorksheet) && (ListHelper.HasOneOrMoreItems(Worksheet.Rows)))
{
// The file I am using to test has 3 rows at the top above the header row. Take this out if I accidently check this in
// worksheet.Rows.RemoveRange(0, 3);
// Set the outputFolder
string outputFolder = OutputFolderControl.Text;
// Set the className (the name of the generated class)
string className = "SalesTaxEntry";
// Create a new instance of a CodeGenerator
CodeGenerator codeGenerator = new CodeGenerator(worksheet, outputFolder, className);
// Generate a class and set the Namespace
bool success = codeGenerator.GenerateClassFromWorksheet("STATS.Objects");
// Show the results
MessageBox.Show("Success: " + success);
}
There is another override to load multiple sheets at once. I will build a sample project when I get some time to build a sample spreadsheet I can give away.
To load multiple sheets:
List<LoadWorksheetInfo> loadWorkSheetsInfo = new List<LoadWorksheetInfo>();
// Add each LoadWorksheetInfo
workbook = ExcellDataLoader.LoadWorkbook(path, loadWorkSheetsInfo)
I will build some helper methods to save writing as much code once I use this a little to know what is needed.
My first test loaded a 12 column spreadsheet with 3,376 rows in just a few seconds.
I have a new project that uses this project as a good sample. Blazor.Excelerate will soon be an online way to create classes from a spreadsheet.
https://github.com/DataJuggler/Blazor.Excelerate
More helper methods and features will be added. The Nuget package has been released: DataJuggler.Excelerate.
Feel free to mention any new features you think would be useful. I can't promise to do them all, but if it is a good fit for this project I will add it.
This code is all brand new, so use with caution until more testing has been done. First tests have been promising.
I just finished adding a Load method, that is code generated when the classes are written.
** I am available for hire if you need help with any size C# / SQL Server project **
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
-
net7.0
- DataJuggler.Net7 (>= 7.0.1)
- EPPlus (>= 4.5.3.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on DataJuggler.Excelerate:
Package | Downloads |
---|---|
DataJuggler.Blazor.Components
This project consists of an ImageButton, ProgressBar, Sprite, TextBoxComponent which can display as a TextBox, Multi-line TextBox or a CheckBox, a ComboBox, CheckedListComboBox, CheckedListBox, Grid, Label and a brand new Calendar Component. The CSS file DataJuggler.Blazor.Components.css contains many useful classes to help style and position objects. This version is for .Net 8.0. |
|
DataJuggler.SQLSnapshot
SQL Snapshot allows you to export a SQL Server database and all data rows to Excel with one line of code passing in a connectionstring and a path. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
9.0.0 | 177 | 11/13/2024 |
8.0.10 | 584 | 9/13/2024 |
8.0.9 | 450 | 9/11/2024 |
8.0.8 | 1,993 | 5/19/2024 |
8.0.7 | 108 | 5/19/2024 |
8.0.6 | 111 | 5/19/2024 |
8.0.5 | 505 | 5/4/2024 |
8.0.4 | 1,268 | 12/29/2023 |
8.0.3 | 426 | 12/29/2023 |
8.0.2 | 1,338 | 12/26/2023 |
8.0.1 | 564 | 11/17/2023 |
8.0.0 | 1,767 | 11/14/2023 |
7.4.6 | 1,233 | 8/28/2023 |
7.4.5 | 1,334 | 8/26/2023 |
7.4.4 | 883 | 8/13/2023 |
7.4.3 | 450 | 8/13/2023 |
7.4.2 | 660 | 7/24/2023 |
7.4.1 | 438 | 7/24/2023 |
7.4.0 | 503 | 7/23/2023 |
7.3.21 | 645 | 7/22/2023 |
7.3.20 | 657 | 7/22/2023 |
7.3.1 | 468 | 7/21/2023 |
7.3.0 | 482 | 7/16/2023 |
7.2.12 | 2,245 | 4/10/2023 |
7.2.11 | 529 | 4/10/2023 |
7.2.10 | 538 | 4/5/2023 |
7.2.9 | 596 | 4/2/2023 |
7.2.8 | 540 | 4/2/2023 |
7.2.7 | 521 | 4/1/2023 |
7.2.6 | 527 | 3/28/2023 |
7.2.5 | 530 | 3/28/2023 |
7.2.4 | 515 | 3/28/2023 |
7.2.3 | 524 | 3/28/2023 |
7.2.2 | 503 | 3/28/2023 |
7.2.1 | 503 | 3/28/2023 |
7.2.0 | 520 | 3/28/2023 |
7.1.12 | 534 | 3/28/2023 |
7.1.11 | 521 | 3/28/2023 |
7.1.10 | 527 | 3/28/2023 |
7.1.9 | 8,587 | 12/25/2022 |
7.1.8 | 6,031 | 12/16/2022 |
7.1.7 | 638 | 12/16/2022 |
7.1.6 | 943 | 12/11/2022 |
7.1.5 | 837 | 12/11/2022 |
7.1.4 | 2,694 | 12/4/2022 |
7.1.3 | 810 | 12/4/2022 |
7.1.2 | 636 | 12/4/2022 |
7.1.1 | 830 | 12/4/2022 |
7.1.0 | 4,412 | 11/15/2022 |
7.0.16 | 1,161 | 11/11/2022 |
7.0.15 | 685 | 11/11/2022 |
7.0.14 | 676 | 11/11/2022 |
7.0.12 | 658 | 11/11/2022 |
7.0.11 | 667 | 11/11/2022 |
7.0.10 | 633 | 11/10/2022 |
7.0.9 | 863 | 11/10/2022 |
7.0.8 | 657 | 11/10/2022 |
7.0.7 | 641 | 11/10/2022 |
7.0.6 | 646 | 11/10/2022 |
7.0.5 | 634 | 11/9/2022 |
7.0.4 | 859 | 11/9/2022 |
7.0.4-rc1 | 450 | 11/8/2022 |
7.0.3-rc1 | 481 | 11/7/2022 |
7.0.2-rc1 | 526 | 11/7/2022 |
7.0.1-rc1 | 432 | 11/7/2022 |
7.0.0-rc1 | 444 | 10/31/2022 |
6.0.3 | 924 | 9/28/2022 |
6.0.2 | 741 | 9/28/2022 |
6.0.1 | 1,018 | 4/1/2022 |
6.0.0 | 1,000 | 1/23/2022 |
1.7.3 | 753 | 11/30/2021 |
1.7.2 | 629 | 11/30/2021 |
1.7.1 | 627 | 11/30/2021 |
1.7.0 | 644 | 11/30/2021 |
1.6.0 | 620 | 11/29/2021 |
1.5.0 | 722 | 11/10/2021 |
1.4.4 | 733 | 11/8/2021 |
1.4.3 | 662 | 11/8/2021 |
1.4.2 | 676 | 11/8/2021 |
1.4.1 | 660 | 11/8/2021 |
1.4.0 | 662 | 11/8/2021 |
1.3.12 | 628 | 11/7/2021 |
1.3.10 | 660 | 11/7/2021 |
1.3.9 | 711 | 11/7/2021 |
1.3.8 | 748 | 11/7/2021 |
1.3.7 | 739 | 11/7/2021 |
1.3.6 | 793 | 11/7/2021 |
1.3.5 | 737 | 11/5/2021 |
1.3.4 | 736 | 11/5/2021 |
1.3.3 | 711 | 11/5/2021 |
1.3.2 | 747 | 11/5/2021 |
1.3.1 | 659 | 11/2/2021 |
1.3.0 | 639 | 11/2/2021 |
1.2.8 | 691 | 11/1/2021 |
1.2.7 | 651 | 10/31/2021 |
1.2.6 | 647 | 10/31/2021 |
1.2.5 | 725 | 10/31/2021 |
1.2.4 | 759 | 10/31/2021 |
1.2.3 | 722 | 10/31/2021 |
1.2.2 | 688 | 10/31/2021 |
1.2.1 | 685 | 10/31/2021 |
1.2.0 | 742 | 10/31/2021 |
1.1.9 | 644 | 10/16/2021 |
1.1.8 | 723 | 10/16/2021 |
1.1.7 | 680 | 10/14/2021 |
1.1.6 | 654 | 10/13/2021 |
1.1.5 | 687 | 9/21/2021 |
1.1.4 | 685 | 9/20/2021 |
1.1.3 | 670 | 9/20/2021 |
1.1.2 | 693 | 9/17/2021 |
1.1.1 | 667 | 9/17/2021 |
1.0.3 | 604 | 9/15/2021 |
1.0.2 | 633 | 9/14/2021 |
1.0.1 | 645 | 9/14/2021 |
1.0.0 | 677 | 9/14/2021 |
11.10.2022 B:
Added a Row property to a Column. Had RowNumber before, but Row gives you access to the parent.
I added a read only property called ReadOnly if EditType == EditTypeEnum.ReadOnly.
Also added a read only property 'IsEditable' which returns true if EditType is not ReadOnly.
Makes it easier to determine if a column is read only or not.
11.10.2022: I added an enumeration for EditorType, and now the column object has an Editortype.
This is only for DataJuggler.Blazor.Components.Grid.
11.9.2022: I added a property EditMode bool for use in Blazor.
11.8.2022: .NET7 is out of preview, so this version is now 7.0.4 (was 7.0.4-rc1).
11.8.2022: I added ClassName property to the row object.
11.7.2022: I added these properties for use with DataJuggler.Blazor.Components.Grid.
Height
Width
Unit
ClassName (used for styling classes using BlazorStyled).
Also had two read only property WidthPlusUnit and HeightPlusUnit.
10.31.2022
v7.0.0-rc1: I updated this project to .NET 7. Use a 6.x version for .NET6.
I will remove the -rc1 once .NET 7 is out of preview.
9.28.2022: I fixed my earlier attempts at improving the data type. I wasn't removing $ signs,
or taking them into account and I was getting strings for doubles. It isn't hard to switch if it
generates wrong, but still I want this to do most of the work.
9.28.2022: I improved the DataType scoring. Before I had a few hard coded items, but today
I built a DataTypeScorer to look at 25 data rows for a column and attempt to determine the data type.
4.1.2022: Version 6.0.1: I added ExcludedColumnIndexes. I have a project for a client and I need to skip two columns.
This is brand new code, and not tested, so use with caution for now. April Fools, my code always works the 1st time!
1.23.2022: This project was updated to .NET6.
11.30.2021 (Take Four)
Version 1.7.3: I fixed IsHeaderRow is set to true for the top row, for data that is loaded in LoadAllData which calls LoadWorksheet.
Now the Load list method checks for the row is not a header row.
11.30.2021 (Take Three)
Version 1.7.2: I changed an if statement to a compound if in CodeGenerator.cs (in the Load List override), and I forgot to
add an extra opening paren. Computers are so picky.
11.30.2021 (Take Two)
Version 1.7.1: I realized the Load method for a list, needed row.Number > 1 and row.HasColumns, because of the
header row means you need to skeep the first row.
11.30.2021
Version 1.7.0: I added a new feature to code generate a Load method override, that accepts a worksheet parameter,
and will load a list of objects now. Saves writing a load method for each worksheet, now one line of code can take car of it.
11.10.2021 (Take Two)
Version 1.5.1: .Net6.0 won't open the file. Testing with .Net 5.0.
11.10.2021
Version 1.5.0: Package now supports mullti-targeting net5.0 and net6.0.
11.8.2021 (Take Four)
Version 1.4.2: My code generated NewRowMethod, used row.Columns.Add(column) instead of newRow.Columns.Add(column). I fixed this to use the variable name newRow.
11.8.2021 (Take Four)
Version 1.4.3: I fixed a stack overflow error (that I caused).
11.8.2021 (Take Three)
Version 1.4.1: I realized I had to add a using statement reference for DataJuggler.Net5
to the code generated classes.
11.8.2021 (Take Two)
Version 1.4.0: The Add New Method code generation appears to work.
I am updating Blazor Excelerate with this version and will continue to test.
11.8.2021
Version 1.3.14: First attempt at code generating the NewRow method.
11.7.2021 (Take Two)
Version 1.3.12: I added two new features:
1. ColumnValue for a boolean column, can now be exported as 0 or 1 (instead of True / False).
To use this, set ExportBooleanAsOneOrZero to true, and the DataType must be a DataManager.DataTypes.Boolean
2. I added a FindColumn method to the row object, to make setting ExportBooleanAsOneOrZero easier.
11.7.2021
Version 1.3.10: BooleanHelper, part of DataJuggler.UltimateHelper had a bug in the ParseBoolean method.
11.6.2021 (Take Four)
Version 1.3.9: I set StringValue to an empty string if an error occurrs.
11.6.2021 (Take Three)
Version 1.3.8: Before 1.3.7 Nuget package email arrived that it was ready, I realized I needed to
create the WorksheetInfo object in the constructor also.
11.6.2021 (Take Two)
Version 1.3.7: While working on Excelerate.WinForms.Deo, I realized I needed to create the Updates collection
and I decided it saved two lines of code in my demo to do this in the constructor.
11.6.2021
Version 1.3.6: I created two new methods SaveBatch and SaveBatchItem.
SaveBatch represents saving data from multple worksheets
SaveBatchItem represents saving data from one worksheet.
Both of these methods are untested, so at this time use with caution.
11.4.2021 (Take Four)
Version 1.3.5: I had forgotten to add saved = true to ExcelHelper.Save method at the end of the Save method.
11.4.2021 (Take Three)
Version 1.3.4: I discovered too late the ExcelHelper.Save method is not static.
11.4.2021 (Take Two)
Version 1.3.3: My previous Save method had the return value in the wrong place.
Hopefully this fixes it. I am too lazy to add the project and propertly debug it.
11.4.2021
Version 1.3.2: While working on Save I realized I needed to return the row from the code generated Save method
so Excel can be updated. Save is still being tested, so use with caution.
11.2.2021 (Take Two)
Version 1.3.1: The previous version code generated the Save method incorrectly. This should fix it.
11.2.2021
Version 1.3.0: I now code generate a Save method, so the current Row.Column's ColumnValues are updated with the current value of this object.
11.1.2021
Version 1.2.8: I updated Worksheet.Columns is now set to first row.Columns when the Worksheet is loaded.
I added a NewRow method, that returns a new row with the columns set.
I updated AttemptToDetermineDataType to set ZipCode and PostalCode fields to a string, not an integer.
Code Generating a Save method is next I think.
10.31.2021 (Take Eight)
This time, DataJuggler.UlimateHelper was updated. The ParseBoolean method got an upgrade.
10.31.2021 (Take Seven)
Version 1.2.6: I updated ParseBoolean to use DataJuggler.UltimateHelper.BooleanHelper.ParseBoolean. We will see if this converts a 1 to a true and a zero to a false. I think it does after 11 years.
10.31.2021: (Take Six)
Version 1.2.5: I fixed Active being a boolean, and discovered the LoadMethod was trying to set bool columns to a string value.
10.31.2021: (Take Five)
Version 1.2.4: I fixed the Active field = boolean. I need an else so the data type didn't get set to Int further in the AttemptToDetermineDataType method.
10.31.2021: (Take Four)
Version 1.2.3: Added a check for data type boolean. To make this work, convert Excel bool values to True False vs 0 and 1.
10.31.2021 (Take Three)
Version 1.2.2: Code generation is fixed with a reference to System is needed since Guid RowId has been added.
10.31.2021 (Take Two)
Version 1.2.1: I messed up the code generation in Version 1.2.0 because the RowId field wasn't getting a field name written. Should work now.
10.31.2021:
Version 1.2.0: The code generation of the RowId seems to work, so the 1.2 version starts the Saving features.
10.31.2021
Version 1.1.10: I added RowNumber and Id (Guid) to class Row to help in saving, which I am just starting.
10.16.2021
Version 1.1.9: I added a new method LoadAllData, which returns a DataJuggler.Excelerate.Workbook, which contains all DataJuggler.Excelerate.Worksheets, which contain all DataJuggler.Excelerate.Rows of data.
10.16.2021:
Version 1.1.8: AppendPartialGuid is now an optional parameter, and only if true will the partial guid be appended to the filename.
10.14.2021:
Version 1.1.7: CodeGenerator.GenerateClassFromWorksheet now returns an object of type CodeGenerationResponse. Previous version only returns a boolean, which wasn't very helpful for the caller.
10.13.2021: New override for GetSheetNames takes a path argument.
I am working on a new Blazor project called Blazor.Excelerate to demo this project.
9.21.2021
Version 1.1.5:
I created an ExcelHelper class because I needed the GetColumnLetter feature of ExcelCellAddress.
9.20.2021
Version 1.1.4:
I updated ExcelDataLoader to havea LoadPackage method.
9.20.2021:
Version 1.1.3:
I added an OriginalFileName property to class Column, so the exported column header can be the same as the original.
9.17.2021
Version 1.1.2:
The Code Generator class is now finished, and a Load method has been updated to test for
a null row or null row.Columns just to be safer.
More updates may come in the future, but for now I have completed what I started this project for.
For the amount of effort I put into this, I think the return on investment is quite satisfactory as
now I can build Excel projects much faster.
9.17.2021
Version 1.1.1: I now code generate a Load method with the Code Generator, so a Row can be used to load an instance of the class created. This is still being tested.
9.15.2021
Version 1.0.3: I added a LoadWorksheet override, so clients do not have to load a Workbook to get
to a single worksheet.
This is the first release. I have just begun adding classes and helper methods to this. It does work for now to load a worksheet and all the Rows / Columns. Each column is loaded as an object ColumnValue, than properties exist that cast the ColumnValue as a bool, datetime, Decimal or other types.