显示 Cell 范围作为数据标签
Contents
[
Hide
]
在 MS Excel 中将单元格范围显示为数据标签
在 Microsoft Excel 2013 中,您可以为数据标签显示 Cell 范围。您可以按照以下步骤选择此选项
- 选择系列的数据标签,然后右键单击以打开弹出菜单。
- 点击格式化数据标签…它会显示标签选项.
- 选中或取消选中复选框标签包含 - 值来自 Cells.
将 Cell 范围显示为数据标签的复选框
以下屏幕截图突出显示了此选项以供您参考。
使用 Aspose.Cells 将单元格范围显示为数据标签
Aspose.Cells 提供了DataLabels.setShowCellRange()选中或取消选中复选框的方法标签包含 - 值来自 Cells如上面的屏幕截图所示。
Java 将单元格范围显示为数据标签的代码
下面的示例代码访问图表系列的数据标签,然后设置DataLabels.setShowCellRange()检查真值的方法标签包含 - 值来自 Cells选项。
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(ShowCellRangeAsTheDataLabels.class); | |
// Create workbook from the source Excel file | |
Workbook workbook = new Workbook(dataDir + "sample.xlsx"); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Access the chart inside the worksheet | |
Chart chart = worksheet.getCharts().get(0); | |
// Check the "Label Contains - Value From Cells" | |
DataLabels dataLabels = chart.getNSeries().get(0).getDataLabels(); | |
dataLabels.setShowCellRange(true); | |
// Save the workbook | |
workbook.save(dataDir + "output.xlsx"); | |