将列宽设置为可伸缩单位,如em或百分比

Contents
[ ]

从电子表格生成HTML文件非常常见. 列的大小以"pt"为单位定义在许多情况下有效. 但是, 也可能存在不需要固定大小的情况. 例如,如果在显示HTML页面的容器面板宽度为600px, 则如果生成的表格宽度更宽,可能会出现水平滚动条. 在这种情况下, 可以将此固定大小改为em或百分比等可扩展的单位以获得更好的呈现效果. 下面的示例代码可以使用其中的HtmlSaveOptions.width_scalable设置为true来创建可扩展宽度.

可从以下链接下载示例源文件和输出文件:

sampleForScalableColumns.xlsx

outsampleForScalableColumns.zip

from aspose.cells import HtmlSaveOptions, Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Load sample source file
wb = Workbook(sourceDir + "sampleForScalableColumns.xlsx")
# Specify Html Save Options
options = HtmlSaveOptions()
# Set the property for scalable width
options.width_scalable = True
# Specify image save format
options.export_images_as_base64 = True
# Save the workbook in Html format with specified Html Save Options
wb.save(outputDir + "outsampleForScalableColumns.html", options)