将单元格范围显示为数据标签

复选框显示单元格范围作为数据标签

在Microsoft Excel中显示单元格范围作为数据标签:

  1. 选择系列数据标签,右键单击以打开上下文菜单。
  2. 选择格式数据标签。标签选项会显示。
  3. 选择或清除选项 标签包含 - 来自单元格的值

下面的示例代码访问图表系列数据标签,并将 DataLabels.ShowCellRange 属性设置为 true 以选择 标签包含 - 来自单元格的值 选项。

// 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);
// Create workbook from the source Excel file
Workbook workbook = new Workbook(dataDir + "source.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Access the chart inside the worksheet
Chart chart = worksheet.Charts[0];
// Check the "Label Contains - Value From Cells"
DataLabels dataLabels = chart.NSeries[0].DataLabels;
dataLabels.ShowCellRange = true;
// Save the workbook
workbook.Save(dataDir + "output_out.xlsx");