セル範囲をデータラベルとして表示する(C++)
Contents
[
Hide
]
Microsoft Excel 2013では、データラベルにセル範囲を表示することができます。Aspose.Cellsはこの機能をサポートしています。
セル範囲をデータラベルとして表示するためのチェックボックス
Microsoft Excelでセルの範囲をデータラベルとして表示するには:
- シリーズのデータラベルを選択して、コンテキストメニューを開くために右クリックします。
- データラベルの書式設定を選択します。ラベルのオプションが表示されます。
- ラベルに値を含めるオプションを選択またはクリアします。
以下のサンプルコードは、チャートシリーズのデータラベルにアクセスし、trueにラベルに値を含めるオプションを選択するためのDataLabels.GetShowCellRange()プロパティを設定します。
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::Charts;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Path of input excel file
U16String inputFilePath = srcDir + u"source.xlsx";
// Path of output excel file
U16String outputFilePath = outDir + u"output_out.xlsx";
// Create workbook from the source Excel file
Workbook workbook(inputFilePath);
// Access the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Access the chart inside the worksheet
Chart chart = worksheet.GetCharts().Get(0);
// Check the "Label Contains - Value From Cells"
DataLabels dataLabels = chart.GetNSeries().Get(0).GetDataLabels();
dataLabels.SetShowCellRange(true);
// Save the workbook
workbook.Save(outputFilePath);
std::cout << "Workbook saved successfully!" << std::endl;
Aspose::Cells::Cleanup();
}