使用 HtmlSaveOptions.TableCssId 属性为表格元素样式添加前缀
Contents
[
Hide
]
可能的使用场景
Aspose.Cells 允许您使用 HtmlSaveOptions.TableCssId 属性为表格元素样式添加前缀。假设您将此属性设置为 MyTest_TableCssId 等某个值,则将找到如下所示的表格元素样式。
table#MyTest_TableCssId
#MyTest_TableCssId tr
#MyTest_TableCssId col
#MyTest_TableCssId br
etc.
以下屏幕截图显示了使用 HtmlSaveOptions.TableCssId 属性对输出 HTML 的影响。
使用 HtmlSaveOptions.TableCssId 属性为表格元素样式添加前缀
以下示例代码说明了如何使用 HtmlSaveOptions.TableCssId 属性。请参考代码生成的 输出 HTML 进行参考。
示例代码
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 | |
//Create workbook object | |
Workbook wb = new Workbook(); | |
//Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Access cell B5 and put value inside it | |
Cell cell = ws.getCells().get("B5"); | |
cell.putValue("This is some text."); | |
//Set the style of the cell - font color is Red | |
Style st = cell.getStyle(); | |
st.getFont().setColor(Color.getRed()); | |
cell.setStyle(st); | |
//Specify html save options - specify table css id | |
HtmlSaveOptions opts = new HtmlSaveOptions(); | |
opts.setTableCssId("MyTest_TableCssId"); | |
//Save the workbook in html | |
wb.save("outputTableCssId.html", opts); |