使用Aspose.Cells for Node.js via C++设置图表图例条目的填充为无
Contents
[
Hide
]
如果你想将图表图例条目的填充文本设置为无,以便它不在图例内显示,请将LegendEntry.isTextNoFill()设置为true。
以下示例代码将图表的第二个图例条目填充的文本设置为无色。请下载这段代码中使用的sample excel file和由此生成的output excel file进行参考。
以下截图突出显示了此代码对示例Excel文件的效果。
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);