Set text of chart legend entry fill to none using Aspose.Cells for Node.js via C++
Contents
[
Hide
]
If you want to set the text of the chart’s legend entry fill to none so that it does not display inside the chart legend, please set the LegendEntry.isTextNoFill() to true.
The following sample code sets the text of the chart’s second legend entry fill to none. Please download the sample excel file used in this code and the output excel file generated by it for your reference.
The following screenshot highlights the effect of this code on the sample excel file.
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Open the template file.
const workbook = new AsposeCells.Workbook(path.join(dataDir, "Sample.xlsx"));
// Access the first worksheet
const sheet = workbook.getWorksheets().get(0);
// Access the first chart inside the sheet
const chart = sheet.getCharts().get(0);
// Set text of second legend entry fill to none
chart.getLegend().getLegendEntries().get(1).setIsTextNoFill(true);
// Save the workbook in xlsx format
workbook.save(path.join(dataDir, "ChartLegendEntry_out.xlsx"), AsposeCells.SaveFormat.Xlsx);