使用Aspose.Cells将图例条目填充的文本设置为无
Contents
[
Hide
]
如果要将图例条目的文本填充设置为无,以便不在图例中显示,请将 LegendEntry.IsTextNoFill 设置为 true。
使用Aspose.Cells将图例条目填充的文本设置为无
以下示例代码将图表的第二个图例条目的填充文本设置为无。请下载此代码中使用的 样本excel文件 和代码生成的 输出excel文件 以供参考。
以下屏幕截图突显了此代码对示例 Excel 文件的影响。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(Settextofchartlegend.class); | |
// Open the template file. | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Access the first worksheet | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
// Access the first chart inside the sheet | |
Chart chart = sheet.getCharts().get(0); | |
// Set text of second legend entry fill to none | |
chart.getLegend().getLegendEntries().get(1).setTextNoFill(true); | |
// Save the workbook in xlsx format | |
workbook.save(dataDir + "output.xlsx", SaveFormat.XLSX); |