https://github.com/fei-sheng-wu/xlsxtohtmlconverter
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.
https://github.com/fei-sheng-wu/xlsxtohtmlconverter
conversion convert converter csharp dotnet excel excel-converter excel-exporter excel-parser excel-to-html html html-creator xlsx xlsx-converter xlsx-exporter xlsx-parser xlsx-to-html
Last synced: 3 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/fei-sheng-wu/xlsxtohtmlconverter
- Owner: Fei-Sheng-Wu
- License: mit
- Created: 2020-05-14T04:01:39.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-22T22:30:25.000Z (over 1 year ago)
- Last Synced: 2025-03-17T09:45:34.836Z (about 1 year ago)
- Topics: conversion, convert, converter, csharp, dotnet, excel, excel-converter, excel-exporter, excel-parser, excel-to-html, html, html-creator, xlsx, xlsx-converter, xlsx-exporter, xlsx-parser, xlsx-to-html
- Language: C#
- Homepage: https://www.nuget.org/packages/XlsxToHtmlConverter
- Size: 6.15 MB
- Stars: 16
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# XlsxToHtmlConverter v2.1.0
[](#)
[](#)
[](#)
[](https://www.nuget.org/packages/XlsxToHtmlConverter)
[](https://www.nuget.org/packages/XlsxToHtmlConverter)
[](#)
[](LICENSE.txt)
> A fast, versatile, and powerful XLSX to HTML converter. Support an extensive scope of cell stylings and additional elements. Empower the efficient transformation of spreadsheets into well-structured web documents. Provide the ability to easily customize every aspect of the conversion process with progress callbacks. Only depend on the Open XML SDK.
## Dependencies
- [DocumentFormat.OpenXml](https://github.com/dotnet/Open-XML-SDK) ≥ 3.0.0, < 4.0.0
## Features
- [x] Cell structures, sizes, fonts, fills, borders, alignments, and visibilities
- [x] Content presentation with number formats and basic conditional formats
- [x] Elements of pictures and shapes with responsive positioning
- [x] HTML construction with configurable details and modernized organization
| Original XLSX File |
| :---: |
|  |
| Converted HTML File |
| :---: |
|  |
## Versioning
For versions ≥ 2.0.0, the versioning of XlsxToHtmlConverter conforms to the following scheme:
| Generation | | Major | | Minor |
| :--- | :---: | :--- | :---: | :--- |
| **2** | . | **1** | . | **0** |
| _(backward-incompatible)_ | | _(backward-incompatible)_ | | _(backward-compatible)_ |
| Significant codebase refactors. | | Severe bug fixes and core improvements. | | Mild changes. |
The changelogs are available at the [Releases](https://github.com/Fei-Sheng-Wu/XlsxToHtmlConverter/releases).
## How to Use
Only one line to convert a local XLSX file to HTML:
```c#
XlsxToHtmlConverter.Converter.Convert(@"C:\path\to\input.xlsx", @"C:\path\to\output.html");
```
Similarly, the use of `Stream` is supported:
```c#
Stream input = ...;
Stream output = ...;
XlsxToHtmlConverter.Converter.Convert(input, output);
```
Alternatively, the input may also be a `DocumentFormat.OpenXml.Packaging.SpreadsheetDocument` instance:
```c#
using DocumentFormat.OpenXml.Packaging;
```
```c#
SpreadsheetDocument input = ...;
Stream output = ...;
XlsxToHtmlConverter.Converter.Convert(input, output);
```
### Conversion Configuration
A third optional parameter can be set to configure the conversion process:
```c#
XlsxToHtmlConverter.ConverterConfiguration configuration = new()
{
BufferSize = 65536,
Encoding = Encoding.UTF8,
NewlineCharacter = "\n",
TabCharacter = new(' ', 2),
RoundingDigits = 2,
CurrentCulture = CultureInfo.CurrentCulture,
HtmlTitle = null,
HtmlPresetStylesheet = ...,
XlsxSheetSelector = null,
ConvertSheetTitles = true,
ConvertSizes = true,
ConvertVisibilities = true,
ConvertStyles = true,
ConvertNumberFormats = true,
ConvertPictures = true,
ConvertShapes = true,
UseHtmlFragment = false,
UseHtmlClasses = true,
UseHtmlHexColors = true,
UseHtmlProportionalWidths = true,
UseHtmlDataElements = true,
...
};
XlsxToHtmlConverter.Converter.Convert(..., ..., configuration);
```
### Progress Callback
A fourth optional parameter can be set to add a progress callback event handler:
```c#
XlsxToHtmlConverter.Converter.Convert(..., ..., ..., HandleProgressChanged);
```
```c#
private void HandleProgressChanged(DocumentFormat.OpenXml.Packaging.SpreadsheetDocument? sender, XlsxToHtmlConverter.ConverterProgressChangedEventArgs e)
{
string summary = $"Sheet {e.CurrentSheet} of {e.SheetCount} | Row {e.CurrentRow} of {e.RowCount}";
string progress = new string('█', (int)Math.Round(e.ProgressPercentage / 100.0 * 50)).PadRight(50, '░');
Console.Write($"{e.ProgressPercentage:F2}% ({summary}) {progress}");
}
```
## License
This project is under the [MIT License](LICENSE.txt).