using IronXL;
using IronXL.Options;
WorkBook workBook = WorkBook.Load("sample.xlsx");
var options = new HtmlExportOptions()
{
// Set row/column numbers visible in html document
OutputRowNumbers = true,
OutputColumnHeaders = true,
// Set hidden rows/columns visible in html document
OutputHiddenRows = true,
OutputHiddenColumns = true,
// Set leading spaces as non-breaking
OutputLeadingSpacesAsNonBreaking = true
};
// Export workbook to the HTML file
workBook.ExportToHtml("workBook.html", options);
Imports IronXL
Imports IronXL.Options
Private workBook As WorkBook = WorkBook.Load("sample.xlsx")
Private options = New HtmlExportOptions() With {
.OutputRowNumbers = True,
.OutputColumnHeaders = True,
.OutputHiddenRows = True,
.OutputHiddenColumns = True,
.OutputLeadingSpacesAsNonBreaking = True
}
' Export workbook to the HTML file
workBook.ExportToHtml("workBook.html", options)
Install-Package IronXL.Excel
將 Excel 轉換為 HTML
上面的程式碼範例示範如何使用 C# 將 Excel 轉換為 HTML。 HtmlExportOptions類別用於自訂 HTML 輸出的產生方式。 可選方案有:
OutputRowNumbers屬性:指示是否在產生的 HTML 檔案中顯示行號。
OutputColumnHeaders屬性:指示是否在產生的 HTML 檔案中顯示列標題。
OutputHiddenRows屬性:指示是否在產生的 HTML 檔案中顯示隱藏行。
OutputHiddenColumns屬性:指示是否在產生的 HTML 檔案中顯示隱藏列。
OutputLeadingSpacesAsNonBreaking屬性:指示是否在產生的 HTML 檔案中將前導空格(儲存格中第一個字元之前的額外空格)顯示為不間斷空格。