C++を使用したチャートポイントのリッチテキストカスタムデータラベル
Contents
[
Hide
]
Aspose.Cellsを使用してチャートポイントのリッチテキストカスタムデータラベルを作成できます。Aspose.CellsはDataLabels.Characters()メソッドを提供しており、FontSettingオブジェクトを返し、フォントの色や太字などの設定に利用できます。
チャートポイントのリッチテキストカスタムデータラベル
以下のコードは最初の系列の最初のチャートポイントにアクセスし、そのテキストを設定し、最初の10文字のフォントを赤色に設定し、太字にします。
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Create a workbook from source Excel file
Workbook workbook(srcDir + u"sample.xlsx");
// Access first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Access the first chart inside the sheet
Chart chart = worksheet.GetCharts().Get(0);
// Access the data label of first series first point
DataLabels dlbls = chart.GetNSeries().Get(0).GetPoints().Get(0).GetDataLabels();
// Set data label text
dlbls.SetText(u"Rich Text Label");
// Set the font setting of the first 10 characters
FontSetting fntSetting = dlbls.Characters(0, 10);
fntSetting.GetFont().SetColor(Color::Red());
fntSetting.GetFont().SetIsBold(true);
// Save the workbook
workbook.Save(srcDir + u"output_out.xlsx");
Aspose::Cells::Cleanup();
}