将列宽设置为可伸缩单位,如em或百分比
Contents
[
Hide
]
从电子表格生成HTML文件非常常见。列的大小定义为"pt",在许多情况下有效。但是,可能会出现不需要固定大小的情况。例如,如果容器面板宽度为600像素,HTML页面在其中显示。这种情况下,如果生成的表格宽度较大,可能会出现水平滚动条。因此,需要将这个固定大小改为可伸缩单位,如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-Java | |
// Load sample source file | |
Workbook wb = new Workbook(srcDir + "sampleForScalableColumns.xlsx"); | |
// Specify Html Save Options | |
HtmlSaveOptions options = new HtmlSaveOptions(); | |
// Set the property for scalable width | |
options.setWidthScalable(true); | |
// Specify image save format | |
options.setExportImagesAsBase64(true); | |
// Save the workbook in Html format with specified Html Save Options | |
wb.save(outDir + "outsampleForScalableColumns.html", options); |