HtmlSaveOptions.TableCssIdプロパティを使用してテーブル要素のスタイルにプリフィックスを付ける(C++)

可能な使用シナリオ

Aspose.Cellsには、ワークシートのCSSをHtmlSaveOptions.GetTableCssId()プロパティで接頭辞としてエクスポートする機能があります。このような値としてMyTest_TableCssIdなどの値を設定すると、以下に示すようなテーブル要素のスタイルが見つかります。

table#MyTest_TableCssId

#MyTest_TableCssId tr

#MyTest_TableCssId col

#MyTest_TableCssId br

etc.

以下のスクリーンショットは、HtmlSaveOptions.GetTableCssId()プロパティの使用による出力HTMLに対する効果を示しています。

todo:image_alt_text

HtmlSaveOptions.TableCssIdプロパティを使用してテーブル要素のスタイルにプレフィックスを付ける

次のサンプルコードは、HtmlSaveOptions.GetTableCssId()プロパティを使用する方法を示しています。コードによって生成されたoutput HTMLの参照用です。

サンプルコード

#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();
}