Visa cellområde som datalabels med Node.js via C++

Kryssrutan för att visa cellområde som datamärken

Att visa cellområdet som datamärken i Microsoft Excel:

  1. Välj seriens datamärken och högerklicka för att öppna snabbmenyn.
  2. Välj Formatera datamärken. Etikettalternativ visas.
  3. Välj eller avmarkera alternativet Etiketten innehåller - Värde från celler.

Koden nedan ger tillgång till en diagramserie datamärkningar och ställer in DataLabels.getShowCellRange()-egenskapen till true för att välja alternativet Label Contains - Value From Cells.

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"));