Convert XLSX to HTML in C#
XlsxToHtmlConverter exports one sheet of a workbook as an HTML table, ready to drop into a page. Every cell is escaped, so a cell holding markup arrives as text.
using DocToolkit;
byte[] xlsx = File.ReadAllBytes("input.xlsx");
string html = XlsxToHtmlConverter.Convert(xlsx, "Sheet1");
File.WriteAllText("output.html", html);What it needs
- No browser, headless or otherwise.
- No Office install, and no LibreOffice.
- No native files: managed code only.
- No network at runtime, unless you ask for it.
Good to know
- Synchronous:
Converttakes the workbook as abyte[]and a sheet name, and returns astring. - A bare
<table>fragment, not a whole document; wrapping it is one line. - The first row becomes
<th>cells inside a<thead>. - Cell text is culture-invariant, the same as the CSV export, so the two never disagree about a cell.