使用 Aspose.Cells 将图表图例条目填充文本设置为无
Contents
[
Hide
]
如果您想将图表图例条目的文本填充设置为无,这样它就不会显示在图表图例中,那么请设置图例条目.IsTextNoFill到真的.
以下示例代码将图表的第二个图例条目填充文本设置为无。请下载示例 excel 文件用于此代码和输出excel文件由它生成供您参考。
下面的截图突出显示了这段代码对示例 excel 文件.
This file contains 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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Open the template file. | |
Workbook workbook = new Workbook(dataDir + "Sample.xlsx"); | |
// Access the first worksheet | |
Worksheet sheet = workbook.Worksheets[0]; | |
// Access the first chart inside the sheet | |
Chart chart = sheet.Charts[0]; | |
// Set text of second legend entry fill to none | |
chart.Legend.LegendEntries[1].IsTextNoFill = true; | |
// Save the workbook in xlsx format | |
workbook.Save(dataDir + "ChartLegendEntry_out.xlsx", SaveFormat.Xlsx); |