Prefix Table Elements Styles with HtmlSaveOptions.TableCssId Property with C++

Possible Usage Scenarios

Aspose.Cells allows you to prefix table element styles with HtmlSaveOptions.GetTableCssId() property. Suppose you set this property to a value such as MyTest_TableCssId, you will see 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 the output HTML.

todo:image_alt_text

Prefix Table Elements Styles with HtmlSaveOptions.TableCssId Property

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

Sample Code

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Create workbook object
    Workbook wb;

    // Access first worksheet
    Worksheet ws = wb.GetWorksheets().Get(0);

    // Access cell B5 and put value inside it
    Cell cell = ws.GetCells().Get(u"B5");
    cell.PutValue(u"This is some text.");

    // Set the style of the cell - font color is Red
    Style st = cell.GetStyle();
    st.GetFont().SetColor(Color::Red());
    cell.SetStyle(st);

    // Specify html save options - specify table css id
    HtmlSaveOptions opts;
    opts.SetTableCssId(u"MyTest_TableCssId");

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

    Aspose::Cells::Cleanup();
}