Bodoconsult.Core.Office 1.0.2

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

// Install Bodoconsult.Core.Office as a Cake Tool
#tool nuget:?package=Bodoconsult.Core.Office&version=1.0.2                

What does the library

Bodoconsult.Core.Office library simplifies creating OpenXml spredsheets (xlsx) for database data in form of System.Data.DataTable objects.

It was developed with the intention to easily export database data to Excel spreadsheets.

How to use the library

The following code samples make usage of repository https://github.com/RobertLeisner/Bodoconsult.Core.Database for accessing Microsoft SqlServer database. The method GetDataTable used below returns a plain old System.Data.DataTable object.

The source code contain NUnit test classes, the following source code is extracted from. The samples below show the most helpful use cases for the library.

Use ExcelLateBinding class

The ExcelLateBinding class uses COM late binding to export a DataTable (in the sample code the variable dt) to an Excel spreadsheet.


            var db = SqlClientConnManager.GetConnManager("Data Source=.\\SQLEXPRESS;Initial Catalog=MediaDb;Integrated Security=True");
            var dt = db.GetDataTable("select top 1000 * from settings");

            var excel = new ExcelLateBinding();
            excel.Status += ExcelStatus;
            excel.NewWorkbook();
            //if (e.ErrorCode != 0) return;

            //excel.NewSheet("Daten");
            excel.SelectSheetFirst("TransactionData");
            excel.Header("Test");
            excel.NumberFormat = "#,##0.000000";
            excel.FillDataTable(dt, 4, 1);

            excel.NewSheet("Daten2");
            excel.Header("Test2");
            excel.NumberFormat = "#,##0.00";
            excel.FillDataTable(dt, 4, 1);

            excel.Dispose();

Use XlsxOpenXml class

The XlsxOpenXml class writes the content of a DataTable (in the sample code the variable dt) directly to an OpenXml spreadsheet file.


            var db = SqlClientConnManager.GetConnManager("Data Source=.\\SQLEXPRESS;Initial Catalog=MediaDb;Integrated Security=True");
            var dt = db.GetDataTable("select top 1000 * from settings");

            var oe = new XlsxOpenXml();
            oe.Status += ExcelStatus;
            oe.Error += ExcelError;
            oe.NumberFormatDouble = "#,##0.000000";
            oe.NewWorkbook(path);

            oe.NewSheet("Daten");

            oe.SelectRange(1, 1);
            oe.Style = XlsxStyles.Header;
            oe.SetValue("Hallo Welt1");
			
            oe.FillDataTable(dt, 4, 1);

            oe.Quit();

About us

Bodoconsult (http://www.bodoconsult.de) is a Munich based software development company.

Robert Leisner is senior software developer at Bodoconsult. See his profile on http://www.bodoconsult.de/Curriculum_vitae_Robert_Leisner.pdf.

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. 
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.2 100 7/22/2024
1.0.1 318 12/17/2022
1.0.0 552 12/17/2020

Migration to .NET 8 and updates dependencies