emやパーセントなどのスケーラブルユニットに列の幅を設定する
Contents
[
Hide
]
スプレッドシートからHTMLファイルを生成するのは一般的です。列のサイズは多くの場合"pt"で定義されていますが、固定サイズが必要ではない場合があります。例えば、HTMLページが表示されるコンテナパネルの幅が600pxである場合。この場合、生成されたテーブルの幅が大きいと水平スクロールバーが表示される可能性があります。より良い表現を得るためには、この固定サイズをemやパーセントなどのスケーラブルユニットに変更する必要があります。次のサンプルコードでは、trueに設定された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-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); |