チャート ポイントのリッチ テキスト カスタム データ ラベル
Contents
[
Hide
]
Aspose.Cells を使用して、チャート ポイントのリッチ テキスト カスタム データ ラベルを作成できます。 Aspose.Cells はDataLabels.characters()メソッドを返すフォント設定色、太さなどのテキストのフォント プロパティを設定するために使用できるオブジェクト。
チャート ポイントのリッチ テキスト カスタム データ ラベル
次のコードは、最初の系列の最初のチャート ポイントにアクセスし、そのテキストを設定してから、最初の 10 文字のフォントを、色を赤に、太字を true に設定して設定します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(RichTextCustomData.class); | |
// Create a workbook from source Excel file | |
Workbook workbook = new Workbook(dataDir + "source.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("Rich Text Label"); | |
// Set the font setting of the first 10 characters | |
FontSetting fntSetting = dlbls.characters(0, 10); | |
fntSetting.getFont().setColor(Color.getRed()); | |
fntSetting.getFont().setBold(true); | |
// Save the workbook | |
workbook.save("output.xlsx"); |