Prefix Table Elements Styles with HtmlSaveOptions.TableCssId property in Node.js via C++

Possible Usage Scenarios

Aspose.Cells allows you to prefix table element styles with HtmlSaveOptions.getTableCssId() property. Suppose you set this property with a value such as MyTest_TableCssId, you will find table element styles as shown below:

table#MyTest_TableCssId

#MyTest_TableCssId tr

#MyTest_TableCssId col

#MyTest_TableCssId br

etc.

The following screenshot shows the effect of using HtmlSaveOptions.getTableCssId() property on output HTML.

todo:image_alt_text

Prefix Table Elements Styles with HtmlSaveOptions.TableCssId property

The following sample code demonstrates how to use the HtmlSaveOptions.getTableCssId() property. Please check the output HTML generated by the code for reference.

Sample Code

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.xlsx");

// Create workbook object
const wb = new AsposeCells.Workbook();

// Access first worksheet
const ws = wb.getWorksheets().get(0);

// Access cell B5 and put a value inside it
const cell = ws.getCells().get("B5");
cell.putValue("This is some text.");

// Set the style of the cell - font color is red
const st = cell.getStyle();
st.getFont().setColor(AsposeCells.Color.Red);
cell.setStyle(st);

// Specify html save options - specify table css id
const opts = new AsposeCells.HtmlSaveOptions();
opts.setTableCssId("MyTest_TableCssId");

// Save the workbook in html
wb.save("outputTableCssId.html", opts);