ExcelDataDump 1.0.0-beta

This is a prerelease version of ExcelDataDump.
dotnet add package ExcelDataDump --version 1.0.0-beta
NuGet\Install-Package ExcelDataDump -Version 1.0.0-beta
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="ExcelDataDump" Version="1.0.0-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ExcelDataDump --version 1.0.0-beta
#r "nuget: ExcelDataDump, 1.0.0-beta"
#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 ExcelDataDump as a Cake Addin
#addin nuget:?package=ExcelDataDump&version=1.0.0-beta&prerelease

// Install ExcelDataDump as a Cake Tool
#tool nuget:?package=ExcelDataDump&version=1.0.0-beta&prerelease

ExcelDataDump

The Easiest and fast way of creating spreadsheets from your "SQL query" structured data.

C# Excel / Spreadsheet Library

Package main features

  • Creates an Excel file from SQL query structured data sets.
  • Create custom column names, by replacing the quirie's key name with a custom text.
  • Add multiple sheets, sheet meta data in a single workbook.
  • Easy to use and requires minimal code.

Getting Started

Install ExcelDataDumpv1.0.0-beta and remember to add the namespace.

Code Sample
creating excel sheets

Because an excel workbook is esentially a collection of sheet, we adopt the same concept here we will require a list (collection) of sheets.

  ExcelReports report = new ExcelReports();                  // Instatiate a Workbook
  List<WorkSheet> workbook = new List<WorkSheet>();          // Instatatiate sheet list

Defining a single worksheet properties.

  WorkSheet sheet = new WorkSheet{
    Type = "report",                                         // Keep this as is for future use. when adding other report types.
    Title = "Add title of your report here",                 // Replace with your report title
    Author = "Your name or organisation's name",             // Replace with your or your organisation's name
    SheetName = "Name of sheet tab",                         // Sheet tab name
    SheetData = allDevices,                                  // SQL query data/object
    Headers = null,                                          // Refer to Headers section** (optional).
    Description = "Report/sheet description",                // Replace with your report description
 };
 workbook.Add(sheet);
** sheet.Headers

Headers property is of type List'<'sheetHeaders'>' , where sheetHeaders is of type (string, string) sheetHeaders - (column_Key, replacement_name)

  • "column_key" is the keyname/ table column name from your data set or sql query
  • "replacement_name" is the new text value to replace the column_key

Creating Headers

  • Example → Replacing two column names with custom,readable and "report friendly" names.
 List<sheetHeaders> headers = new List<sheetHeaders>();            
 headers.Add(new sheetHeaders("CustName", "Customer Name"));       // Original text "CustName" will be replaced with "Customer Name"
 headers.Add(new sheetHeaders("CustID", "Account Reference No.")); // Original text "CustID" will be replaced with "Account Reference No."

result

MemoryStream results = report.CreateExcelDocument(workbook);       // Download - handle the return results accordingly (return to UI). 
Putting it all togather - Final code sample (Sever-side code)
    // Instatiate a Workbook and sheets
    ExcelReports report = new ExcelReports();
    List<WorkSheet> workbook = new List<WorkSheet>();

    // creating sheet data and meta data
    WorkSheet sheet = new WorkSheet{
        Type = "report",
        Title = "Add title of your report here",
        Author = "Your name or organisation's name",
        SheetName = "Name of sheet tab",
        SheetData = allDevices,
        Headers = null,
        Description = "Report/sheet description",
    };
    workbook.Add(sheet);
    
    // Adding custom headers
    List<sheetHeaders> headers = new List<sheetHeaders>();
    headers.Add(new sheetHeaders("CustName", "Customer Name"));
    headers.Add(new sheetHeaders("CustID", "Account Reference No."));

    // Handle results (return back to UI)
    MemoryStream results = report.CreateExcelDocument(workbook);
    return results;
UI (Client-side code - Javascript example)

Example of Client side code required to download the generated file.

function exportToExcel(){

    var xhr = new XMLHttpRequest();
    xhr.open("POST", "<https://replaceWithYourApiURL>", true);                // Replace <https://replaceWithYourApiURL> with API URL
    xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
    //Handle Error
    xhr.onerror = function() {
        console.log(`Error during the upload: ${xhr.status}`);
    };
    //Handle Success
    xhr.responseType = "blob";
    xhr.onload = function(e) {
        if (this.status == 200) {
            var blob = this.response;
            saveAs(blob, "<MyExcelFile>.xlsx");                               // Replace <MyExcelFile> with file name.
        }
    };
    xhr.send(JSON.stringify(self.feedbackData));
}

Please share your experience, comments and suggestions. Happy coding!!

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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
1.0.0-beta 309 3/9/2020
1.0.0-alpha 290 3/9/2020