HtmlSaveOptions.TableCssIdプロパティでテーブル要素スタイルをプレフィックス
Contents
[
Hide
]
可能な使用シナリオ
Aspose.Cellsには、ワークシートのCSSをHtmlSaveOptions.table_css_idプロパティで接頭辞としてエクスポートする機能があります。このような値としてMyTest_TableCssIdなどの値を設定すると、以下に示すようなテーブル要素のスタイルが見つかります。
table#MyTest_TableCssId
#MyTest_TableCssId tr
#MyTest_TableCssId col
#MyTest_TableCssId br
etc.
以下のスクリーンショットは、HtmlSaveOptions.table_css_idプロパティの使用による出力HTMLに対する効果を示しています。
HtmlSaveOptions.TableCssIdプロパティの使用方法についてのサンプルコードを以下に説明します。参照のために、コードによって生成されたoutput HTMLを確認してください。
次のサンプルコードは、HtmlSaveOptions.table_css_idプロパティを使用する方法を示しています。コードによって生成されたoutput HTMLの参照用です。
サンプルコード
This file contains hidden or 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
from aspose.cells import HtmlSaveOptions, Workbook | |
from aspose.pydrawing import Color | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook object | |
wb = Workbook() | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Access cell B5 and put value inside it | |
cell = ws.cells.get("B5") | |
cell.put_value("This is some text.") | |
# Set the style of the cell - font color is Red | |
st = cell.get_style() | |
st.font.color = Color.red | |
cell.set_style(st) | |
# Specify html save options - specify table css id | |
opts = HtmlSaveOptions() | |
opts.table_css_id = "MyTest_TableCssId" | |
# Save the workbook in html | |
wb.save("outputTableCssId.html", opts) |