XlsxToHtmlConverter 1.2.13
See the version list below for details.
dotnet add package XlsxToHtmlConverter --version 1.2.13
NuGet\Install-Package XlsxToHtmlConverter -Version 1.2.13
<PackageReference Include="XlsxToHtmlConverter" Version="1.2.13" />
paket add XlsxToHtmlConverter --version 1.2.13
#r "nuget: XlsxToHtmlConverter, 1.2.13"
// Install XlsxToHtmlConverter as a Cake Addin #addin nuget:?package=XlsxToHtmlConverter&version=1.2.13 // Install XlsxToHtmlConverter as a Cake Tool #tool nuget:?package=XlsxToHtmlConverter&version=1.2.13
XlsxToHtmlConverter
A Xlsx to Html file converter and parser. Support cell fill, font, border, alignment and other styles. Support custom column width and row height. Support vertical and/or horizontal merged cells. Support sheet tab color and hidden sheet. Support pictures. Support progress callback. It targets both .Net 5.0 and .Net Core 3.0, and only depends on the Open Xml SDK.
Dependencies
DocumentFormat.OpenXml = 2.10.1
Main Features
- Cell fill, font, border, alignment, and other styles
- Custom column width and row height
- Vertical and/or horizontal merged cells
- Sheet tab color and hidden sheet
- Pictures embedding as Base64 images
- Conversion progress callback
Original Xlsx 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
A local xlsx file can be opened and read into a MemoryStream
, and a FileStream
can be used to write the output html into a local file.
using (MemoryStream inputStream = new MemoryStream())
{
byte[] byteArray = File.ReadAllBytes(xlsxFileName);
inputStream.Write(byteArray, 0, byteArray.Length);
using FileStream outputStream = new FileStream(htmlFileName, FileMode.Create)
{
XlsxToHtmlConverter.Converter.ConvertXlsx(inputStream, outputStream);
}
}
Conversion Configurations
ConverterConfig
include flexible and customizable conversion configurations.
XlsxToHtmlConverter.ConverterConfig config = new XlsxToHtmlConverter.ConverterConfig()
{
PageTitle = "My Title",
PresetStyles = "body { background-color: skyblue; } table { width: 100%; }",
ErrorMessage = "Oh, no. An error occured.",
Encoding = System.Text.Encoding.UTF8,
ConvertStyle = true,
ConvertSize = true,
ConvertPicture = true,
ConvertSheetNameTitle = true,
ConvertHiddenSheet = false,
ConvertFirstSheetOnly = false,
ConvertHtmlBodyOnly = false
}
Progress Callback
A progress callback event can be set up with a EventHandler<ConverterProgressCallbackEventArgs>
, where things like ProgressPercent
can be used.
EventHandler<XlsxToHtmlConverter.ConverterProgressCallbackEventArgs> progressCallback = null;
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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 | netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
-
.NETCoreApp 3.0
- DocumentFormat.OpenXml (>= 2.10.1)
-
net5.0
- DocumentFormat.OpenXml (>= 2.10.1)
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 | 133 | 9/22/2024 |
1.2.19 | 147 | 9/1/2024 |
1.2.18 | 118 | 8/15/2024 |
1.2.17 | 89 | 8/7/2024 |
1.2.15 | 322 | 3/17/2024 |
1.2.13 | 115 | 3/17/2024 |
1.2.7 | 118 | 3/10/2024 |
1.2.1 | 106 | 2/20/2024 |
1.1.15 | 158 | 2/20/2024 |
1.1.14 | 17,997 | 10/8/2020 |
1.1.12 | 487 | 10/5/2020 |
1.1.11 | 629 | 10/3/2020 |
1.1.8 | 496 | 6/22/2020 |