From 8f189a4d31ff08ffe671ab51a1d9626df7af7d78 Mon Sep 17 00:00:00 2001 From: Mitchel Sellers Date: Fri, 10 Jun 2022 00:08:53 -0500 Subject: [PATCH 1/4] Updated all dependencies --- .../NetCore.Utilities.Spreadsheet.Tests.csproj | 8 ++++---- .../NetCore.Utilities.Spreadsheet.csproj | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NetCore.Utilities.Spreadsheet.Tests/NetCore.Utilities.Spreadsheet.Tests.csproj b/src/NetCore.Utilities.Spreadsheet.Tests/NetCore.Utilities.Spreadsheet.Tests.csproj index a414c47..d1d6abd 100644 --- a/src/NetCore.Utilities.Spreadsheet.Tests/NetCore.Utilities.Spreadsheet.Tests.csproj +++ b/src/NetCore.Utilities.Spreadsheet.Tests/NetCore.Utilities.Spreadsheet.Tests.csproj @@ -7,15 +7,15 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/NetCore.Utilities.Spreadsheet/NetCore.Utilities.Spreadsheet.csproj b/src/NetCore.Utilities.Spreadsheet/NetCore.Utilities.Spreadsheet.csproj index f6fa4f5..897da40 100644 --- a/src/NetCore.Utilities.Spreadsheet/NetCore.Utilities.Spreadsheet.csproj +++ b/src/NetCore.Utilities.Spreadsheet/NetCore.Utilities.Spreadsheet.csproj @@ -34,7 +34,7 @@ - + all From f02d3b31692ba124f6f6379bdb7bbd35d1612d43 Mon Sep 17 00:00:00 2001 From: Mitchel Sellers Date: Fri, 10 Jun 2022 00:09:50 -0500 Subject: [PATCH 2/4] Updated sample dependencies --- .../NetCore.Utilities.SpreadsheetExample.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/NetCore.Utilities.SpreadsheetExample/NetCore.Utilities.SpreadsheetExample.csproj b/samples/NetCore.Utilities.SpreadsheetExample/NetCore.Utilities.SpreadsheetExample.csproj index 7a11e3b..251c964 100644 --- a/samples/NetCore.Utilities.SpreadsheetExample/NetCore.Utilities.SpreadsheetExample.csproj +++ b/samples/NetCore.Utilities.SpreadsheetExample/NetCore.Utilities.SpreadsheetExample.csproj @@ -6,7 +6,7 @@ - + From 22e476f757aaffeaea933efd758ce54e568d9310 Mon Sep 17 00:00:00 2001 From: Mitchel Sellers Date: Fri, 10 Jun 2022 00:39:26 -0500 Subject: [PATCH 3/4] Updated to resolve #34 and #33 --- README.md | 20 ++++++++++++++++- .../Program.cs | 22 +++++++++---------- .../OpenXmlSpreadsheetGenerator.cs | 9 +++----- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index a5f4e46..c89fc92 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,28 @@ var fileContent = exportGenerator.CreateSingleSheetSpreadsheet(exportDefinition) System.IO.File.WriteAllBytes("Sample.xlsx", fileContent); ``` +## Sample Multi-Sheet Document Export + +A streamlined fluent syntax is available to export multiple sheets of content. + +```csharp +var multiSheetDefinition = new MultisheetConfiguration() + .WithSheet("Sheet 1", GetSampleExportData(100)) + .WithSheet("Additional Sheet", GetSampleExportData(500), config => + { + config.DocumentTitle = "Lots of data"; + config.RenderTitle = true; + }); + +var multiFileContent = exportGenerator.CreateMultiSheetSpreadsheet(multiSheetDefinition); +System.IO.File.WriteAllBytes("Sample-Multi.xlsx", multiFileContent); +``` + ## Key Features This package is primarily geared towards the exporting of lists of objects into excel sheets. The following key features are supported. * The ability to have one, or more, sheets of data exported * The ability to have a heading and subheading if desired * Data type formatting for Date & Currency fields -* Auto-fit of all columns for display \ No newline at end of file +* Auto-fit of all columns for display +* Support for Curreny, Date, F0, F1, and F2 fixed date formats \ No newline at end of file diff --git a/samples/NetCore.Utilities.SpreadsheetExample/Program.cs b/samples/NetCore.Utilities.SpreadsheetExample/Program.cs index e18c267..59074df 100644 --- a/samples/NetCore.Utilities.SpreadsheetExample/Program.cs +++ b/samples/NetCore.Utilities.SpreadsheetExample/Program.cs @@ -29,18 +29,16 @@ static void Main(string[] args) var fileContent = exportGenerator.CreateSingleSheetSpreadsheet(exportDefinition); System.IO.File.WriteAllBytes("Sample.xlsx", fileContent); - var multiSheet = new List>(); - multiSheet.Add(exportDefinition); - multiSheet.Add(new SpreadsheetConfiguration - { - RenderTitle = true, - DocumentTitle = "Sample Second of 50 Records", - RenderSubTitle = true, - DocumentSubTitle = "Showing the full options", - ExportData = GetSampleExportData(50), - WorksheetName = "Additional" - }); - var multiFileContent = exportGenerator.CreateMultiSheetSpreadsheet(multiSheet); + //Sample 2 sheet export + var multiSheetDefinition = new MultisheetConfiguration() + .WithSheet("Sheet 1", GetSampleExportData(100)) + .WithSheet("Additional Sheet", GetSampleExportData(500), config => + { + config.DocumentTitle = "Lots of data"; + config.RenderTitle = true; + }); + + var multiFileContent = exportGenerator.CreateMultiSheetSpreadsheet(multiSheetDefinition); System.IO.File.WriteAllBytes("Sample-Multi.xlsx", multiFileContent); Console.WriteLine("Files Created"); Console.ReadLine(); diff --git a/src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs b/src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs index 7cdb990..d8b9a16 100644 --- a/src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs +++ b/src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs @@ -111,7 +111,6 @@ public bool CreateMultiSheetSpreadsheet(Stream output, IEnumerable cells) var maxWidth = 0; //TODO: Be smarter about this for our set styles - var numberStyles = new UInt32[] { 5, 6, 7, 8 }; //styles that will add extra chars + var numberStyles = new UInt32[] { 7, 8 }; //styles that will add extra chars var boldStyles = new UInt32[] { 1, 2, 3, 4, 6, 7, 8 }; //styles that will bold //using cell index as my column From 38e7c0e801d08e7d1dd3db1db4b2f791eabbf1f2 Mon Sep 17 00:00:00 2001 From: Mitchel Sellers Date: Fri, 10 Jun 2022 00:41:13 -0500 Subject: [PATCH 4/4] +semver: major --- .../OpenXmlSpreadsheetGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs b/src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs index d8b9a16..821334f 100644 --- a/src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs +++ b/src/NetCore.Utilities.Spreadsheet/OpenXmlSpreadsheetGenerator.cs @@ -446,7 +446,7 @@ private static int GetMaxCharacterWidth(IList cells) //iterate over all cells getting a max char value for each column var maxWidth = 0; - //TODO: Be smarter about this for our set styles + //TODO: Adjust this to use Enum & Validate all style formats var numberStyles = new UInt32[] { 7, 8 }; //styles that will add extra chars var boldStyles = new UInt32[] { 1, 2, 3, 4, 6, 7, 8 }; //styles that will bold