ExcelFromList 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package ExcelFromList --version 1.0.2                
NuGet\Install-Package ExcelFromList -Version 1.0.2                
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="ExcelFromList" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ExcelFromList --version 1.0.2                
#r "nuget: ExcelFromList, 1.0.2"                
#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 ExcelFromList as a Cake Addin
#addin nuget:?package=ExcelFromList&version=1.0.2

// Install ExcelFromList as a Cake Tool
#tool nuget:?package=ExcelFromList&version=1.0.2                

ExcelFromList

Straightforward and easy way to create stylized excel workbooks from lists. Add an image, title, subtitles and overal cell styles/formats. This uses the EPPlus engine, you can check them out at: https://github.com/EPPlusSoftware/EPPlus

In the below examples outputFileName is a string identifying a full path file name and shelfLifeData is a list of ShelfLife type objects.

You can run these same examples in the Testing project.

Default styles (no style object provided)

  var wb = new ExcelWorkBook();
  wb.AddSheet("Shelf Life", shelfLifeData);
  wb.SaveAs(outputFileName);

Default styles

For the rest of the examples a style object has been privided

With title and subtitles

  var wb = new ExcelWorkBook();
  var style = new ExcelStyleConfig
  {
      Title = "Product Shelf Life List",
      Subtitles = new string[]
      {
          "As of 2/1/06",
          "Compiled by the Food Bank",
          "From National Manufactures"
      }
  };

  wb.AddSheet("Shelf Life", shelfLifeData, style);
  wb.SaveAs(outputFileName);

Title and subtitles

With title, subtitles and image

  var wb = new ExcelWorkBook();
  var style = new ExcelStyleConfig
  {
      Title = "Product Shelf Life List",
      Subtitles = new string[]
      {
          "As of 2/1/06",
          "Compiled by the Food Bank",
          "From National Manufactures"
      },
      Base64Image = "iVBORw..." // string trucated for brevity of example
  };

  wb.AddSheet("Shelf Life", shelfLifeData, style);
  wb.SaveAs(outputFileName);

Title, subtitles and image

With title, subtitles, image, two sheets and cell stylings

  var wb = new ExcelWorkBook();
  var sheetOneStyle = new ExcelStyleConfig
  {
      Title = "Product Shelf Life List",
      Subtitles = new string[]
      {
          "As of 2/1/06",
          "Compiled by the Food Bank",
          "From National Manufactures"
      },
      Base64Image = "iVBORw..." // string trucated for brevity of example
  };
  var sheetTwoStyle = new ExcelStyleConfig
  {
      Title = "Food Nutrient Information",
      Subtitles = new string[]
      {
          "List of EDNP products",
          "Audited by category"
      },
      Base64Image = "iVBORw..." // string trucated for brevity of example
      ShowGridLines = false,
      BorderAround = true,
      Border = true,
      BorderColor = Color.CadetBlue,
      HeaderBackgroundColor = Color.Yellow,
      HeaderFontColor = Color.Black
  };

  wb.AddSheet("Shelf Life", shelfLifeData, sheetOneStyle);
  wb.AddSheet("Food Nutrients", foodInfoData, sheetTwoStyle);
  wb.SaveAs(outputFileName);

Title, subtitles, image and two sheets

Documentation

Available in the ExcelStyleConfig class

Sheet configs

ShowHeaders: Enable to show headers (taken from the property name), defaults to true ShowGridLines: Enable to show grid lines, defaults to true AutoFitColumns: Enable to match the width of the column to the data length, defaults to true FreezePanes: Enable to freeze the first row, defaults to true PaddingColumns: Gets or sets the number of columns to insert before column A, defaults to 0 PaddingRows: Gets or sets the number of rows to insert before row 1, defaults to 0

Title configs

Title: Gets or sets the title of the sheet, defaults to null Subtitles: Gets or sets the subtitles of the sheet, defaults to new string[0] Base64Image: Gets or sets a base64 image to be placed on the sheet, defaults to null

Data type formatting

DateFormat: Gets or sets custom Excel format string, defaults to m/d/yyyy DecimalFormat: Gets or sets custom Excel format string, defaults to #,##0.00_);[Red]-#,##0.00 DoubleFormat: Gets or sets custom Excel format string, defaults to #,##0.00_);[Red]-#,##0.00 IntFormat: Gets or sets custom Excel format string, defaults to #,##0_);[Red]-#,##0 <i>* Uses Excel type data formatting</i>

Data cell configs

FontColor: Gets or sets data cell font color, defaults to null BackgroundColor: Gets or sets data cell background color, defaults to null Border: Enable to draw a border around each data cell, defaults to false BorderAround: Enable to draw a border around the data range, defaults to false BorderColor: Gets or sets the border color around each data cell, defaults to Color.Black BorderAroundColor: Gets or sets the border color around the data range, defaults to Color.Black BorderStyle: Gets or sets the border style around each data cell, defaults to ExcelBorderStyle.Thin BorderAroundStyle: Gets or sets the border style around the data range, defaults to ExcelBorderStyle.Thin

Header cell configs

HeaderFontColor: Gets or sets the header font color, defaults to Color.LightGray HeaderBackgroundColor: Gets or sets the header background color, defaults to Color.DarkSlateGray HeaderBorder: Enable to draw a border around each header cell, defaults to false HeaderBorderAround: Enable to draw a border around the header range, defaults to false HeaderBorderColor: Gets or sets the border color around each header cell, defaults to Color.Black HeaderBorderAroundColor: Gets or sets the border color around the header range, defaults to Color.Black HeaderBorderStyle: Gets or sets the border style around each header cell, defaults to ExcelBorderStyle.Thin HeaderBorderAroundStyle: Gets or sets the border style around the header range, defaults to ExcelBorderStyle.Thin

Available in the ExcelWorkBook class

Methods

GetBytesArray: Returns the ExcelWorkBook bytes array AddSheet: Adds a sheet to the worksheet, will apply style config if provided RemoveSheet: Removes a sheet from the worksheet ClearWorkSheet: Removes all sheets from worksheet SheetExists: Checks if a specific sheet exists SaveAs: Saves the workbook to an Excel file Open: Opens saved Excel file with OS default program

For new features you can contact me at raulmarquezi@gmail.com

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 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.6.0 1,157 5/25/2020
1.5.1 445 4/24/2020
1.4.0 547 4/12/2020
1.3.0 510 4/11/2020
1.2.0 529 4/11/2020
1.1.1 506 4/10/2020
1.0.4 449 4/10/2020
1.0.3 550 4/8/2020
1.0.2 488 4/8/2020
1.0.1 549 4/7/2020
1.0.0 473 4/7/2020

Added font and background color for data cells