将列宽设置为可伸缩单位,如em或百分比
Contents
[
Hide
]
从电子表格生成HTML文件非常常见. 列的大小以"pt"为单位定义在许多情况下有效. 但是, 也可能存在不需要固定大小的情况. 例如,如果在显示HTML页面的容器面板宽度为600px, 则如果生成的表格宽度更宽,可能会出现水平滚动条. 在这种情况下, 可以将此固定大小改为em或百分比等可扩展的单位以获得更好的呈现效果. 下面的示例代码可以使用其中的HtmlSaveOptions.WidthScalable设置为true来创建可扩展宽度.
可从以下链接下载示例源文件和输出文件:
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); |