Prefix Table Elements Styles with HtmlSaveOptions.TableCssId property
Possible Usage Scenarios
Aspose.Cells allows you to prefix table elements styles with HtmlSaveOptions.table_css_id property. Suppose, you set this property with some value like MyTest_TableCssId, then you will find table elements styles like shown below
table#MyTest_TableCssId
#MyTest_TableCssId tr
#MyTest_TableCssId col
#MyTest_TableCssId br
etc.
The following screenshot shows the effect of using HtmlSaveOptions.table_css_id property on output HTML.
Prefix Table Elements Styles with HtmlSaveOptions.TableCssId property
The following sample code demonstrates how to make use of HtmlSaveOptions.table_css_id property. Please check the output HTML generated by the code for a reference.
Sample Code
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) |