Node.js経由でC++を使ったセル範囲のデータラベル表示

セル範囲をデータラベルとして表示するためのチェックボックス

Microsoft Excelでセルの範囲をデータラベルとして表示するには:

  1. シリーズのデータラベルを選択して、コンテキストメニューを開くために右クリックします。
  2. データラベルの書式設定を選択します。ラベルのオプションが表示されます。
  3. ラベルに値を含めるオプションを選択またはクリアします。

以下のサンプルコードは、チャートシリーズのデータラベルにアクセスし、そのDataLabels.getShowCellRange()プロパティをtrueに設定して、「セル値からのラベル」オプションを選択します。

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "source_show_range.xlsx");

// Create workbook from the source Excel file
const workbook = new AsposeCells.Workbook(filePath);

// Access the first worksheet
const worksheet = workbook.getWorksheets().get(0);

// Access the chart inside the worksheet
const chart = worksheet.getCharts().get(0);

// Check the "Label Contains - Value From Cells"
const dataLabels = chart.getNSeries().get(0).getDataLabels();
dataLabels.setShowCellRange(true);

// Save the workbook
workbook.save(path.join(dataDir, "output_out.xlsx"));