Showing Cell Range as the Data Labels with Node.js via C++
Contents
[
Hide
]
In Microsoft Excel 2013, you can display a cell range for data labels. Aspose.Cells for Node.js supports this feature.
Check-box to Show Cell Range as Data Labels
To show the cell range as data labels in Microsoft Excel:
- Select the series data labels and right-click to open the context menu.
- Select Format Data Labels. Label options are displayed.
- Select or clear the option Label Contains - Value From Cells.
The sample code below accesses a chart series data labels and sets the DataLabels.getShowCellRange() property to true to select the Label Contains - Value From Cells option.
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"));