将列宽设置为可缩放单位,如 em 或百分比
Contents
[
Hide
]
从电子表格生成 HTML 文件非常常见。列的大小以“pt”定义,这在许多情况下都有效。但是,可能存在不需要此固定大小的情况。例如,如果显示此 HTML 页面的容器面板宽度为 600 像素。在这种情况下,如果生成的表格宽度更大,您可能会得到一个水平滚动条。要求将此固定大小更改为可缩放的单位,如 em 或 percent,以获得更好的显示效果。以下示例代码可用于HtmlSaveOptions.WidthScalable被设置为真的用于创建可缩放宽度。
示例源文件和输出文件可以从以下链接下载:
outsampleForScalableColumns.zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Load sample source file | |
Workbook wb = new Workbook(sourceDir + "sampleForScalableColumns.xlsx"); | |
// Specify Html Save Options | |
HtmlSaveOptions options = new HtmlSaveOptions(); | |
// Set the property for scalable width | |
options.WidthScalable = true; | |
// Specify image save format | |
options.ExportImagesAsBase64 = true; | |
// Save the workbook in Html format with specified Html Save Options | |
wb.Save(outputDir + "outsampleForScalableColumns.html", options); |