使用 HtmlSaveOptions.TableCssId 属性为表元素样式添加前缀

可能的使用场景

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生成的代码供参考。

示例代码

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Create workbook object
Workbook wb = new Workbook();
//Access first worksheet
Worksheet ws = wb.Worksheets[0];
//Access cell B5 and put value inside it
Cell cell = ws.Cells["B5"];
cell.PutValue("This is some text.");
//Set the style of the cell - font color is Red
Style st = cell.GetStyle();
st.Font.Color = Color.Red;
cell.SetStyle(st);
//Specify html save options - specify table css id
HtmlSaveOptions opts = new HtmlSaveOptions();
opts.TableCssId = "MyTest_TableCssId";
//Save the workbook in html
wb.Save("outputTableCssId.html", opts);