XlsxToHtmlConverter 1.2.20

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

// Install XlsxToHtmlConverter as a Cake Tool
#tool nuget:?package=XlsxToHtmlConverter&version=1.2.20                

XlsxToHtmlConverter v1.2.20

C# Target Framework Target Framework Nuget Lincense

A fast Xlsx to Html file converter. Support cell fills, fonts, borders, alignments, and other styles. Support different cell sizes and merged cells. Support custom number formats and basic conditions. Support multiple sheets and hidden sheets. Support embedded pictures. Support progress callbacks. Only depend on the Microsoft Open Xml SDK.

Dependencies

DocumentFormat.OpenXml ≥ 3.0.0

Main Features

  • Cell fills, fonts, borders, alignments, and other styles
  • Custom column widths and row heights
  • Vertical and horizontal merged cells
  • Number formats and basic conditional formats
  • Sheet tab titles, colors, and hidden sheets
  • Picture embeddings as Base64 images
  • Conversion progress callback

Original Xlsx File

Original Xlsx File

Converted Html File

Converted Html File

How to Use

Only one line to convert a Xlsx file to Html with the use of Stream.

XlsxToHtmlConverter.Converter.ConvertXlsx(inputStream, outputStream);

Or to convert with specific ConverterConfig and progress callback.

XlsxToHtmlConverter.Converter.ConvertXlsx(inputStream, outputStream, config, progressCallback);

Convert Local Files

Just use a string of the path to the file instead of a Stream to convert a local Xlsx file.

string filename = @"C:\path\to\file.xlsx";
XlsxToHtmlConverter.Converter.ConvertXlsx(filename, outputStream);

A third optional parameter can be set to decide whether to use a MemoryStream or a FileStream. When set to true, a MemoryStream is used to load the entire file at once instead of reading the file with a FileStream.

Please note that using a MemoryStream will use up significantly more memory, especially for larger files.

XlsxToHtmlConverter.Converter.ConvertXlsx(filename, outputStream, true);

Conversion Configurations

ConverterConfig include flexible and customizable conversion configurations.

In rare cases where the converter is unable to produce the correct stylings, it is suggested to set ConvertStyles to false, which will at least ensure the conversion of all the content with default stylings.

XlsxToHtmlConverter.ConverterConfig config = new XlsxToHtmlConverter.ConverterConfig()
{
    PageTitle = "My Title",
    PresetStyles = XlsxToHtmlConverter.ConverterConfig.DefaultPresetStyles + " body { background-color: skyblue; } table { width: 100%; }",
    ErrorMessage = "An unhandled error occured during the conversion: {EXCEPTION}",
    Encoding = System.Text.Encoding.UTF8,
    BufferSize = 65536,
    ConvertStyles = true,
    ConvertSizes = true,
    ConvertNumberFormats = true,
    ConvertPictures = true,
    ConvertShapes = true,
    ConvertSheetTitles = true,
    ConvertHiddenSheets = false,
    ConvertFirstSheetOnly = false,
    ConvertHtmlBodyOnly = false,
    UseHtmlStyleClasses = true,
    UseHexColors = true,
    RoundingDigits = 2
};

Progress Callback

A progress callback event can be set up with ConverterProgressCallbackEventArgs, where things like ProgressPercent can be used.

EventHandler<XlsxToHtmlConverter.ConverterProgressCallbackEventArgs> progressCallback = ConverterProgressCallback;
private static void ConverterProgressCallback(object sender, XlsxToHtmlConverter.ConverterProgressCallbackEventArgs e)
{
    string info = string.Format("{0:##0.00}% (Sheet {1} of {2} | Row {3} of {4})", e.ProgressPercent, e.CurrentSheet, e.TotalSheets, e.CurrentRow, e.TotalRows);
    string progress = new string('█', (int)(e.ProgressPercent / 2)) + new string('░', (int)((100 - e.ProgressPercent) / 2));
    Console.WriteLine(info + new string(' ', 5) + progress);
}

License

This project is under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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.2.20 175 9/22/2024
1.2.19 176 9/1/2024
1.2.18 127 8/15/2024
1.2.17 113 8/7/2024
1.2.15 482 3/17/2024
1.2.13 120 3/17/2024
1.2.7 123 3/10/2024
1.2.1 111 2/20/2024
1.1.15 165 2/20/2024
1.1.14 18,463 10/8/2020
1.1.12 494 10/5/2020
1.1.11 634 10/3/2020
1.1.8 503 6/22/2020