设置数据透视表选项 - 对于空 Cells 显示
Contents
[
Hide
]
您可以使用 Aspose.Cells 设置不同的数据透视表选项。其中一个选项是“显示空单元格”。通过设置此选项,数据透视表中的所有空单元格都显示为指定的字符串。
在 Microsoft Excel 中设置数据透视表选项
要在 Microsoft Excel 中查找并设置此选项:
- 选择数据透视表并单击鼠标右键。
- 选择数据透视表选项.
- 选择布局和格式标签。
- 选择对于空单元格显示选项并指定一个字符串。
使用 Aspose.Cells 设置数据透视表选项
Aspose.Cells 提供了数据透视表.DisplayNullString和数据透视表.NullString用于设置“对于空单元格显示”数据透视表选项的属性。
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); | |
Workbook wb = new Workbook(dataDir + "input.xlsx"); | |
PivotTable pt = wb.Worksheets[0].PivotTables[0]; | |
// Indicating if or not display the empty cell value | |
pt.DisplayNullString = true; | |
// Indicating the null string | |
pt.NullString = "null"; | |
pt.CalculateData(); | |
pt.RefreshDataOnOpeningFile = false; | |
wb.Save(dataDir+ "output_out.xlsx"); |