Setting Pivot Table Option - For Empty Cells Show

How to Set Pivot Table Option in Microsoft Excel

To find and set this option in Microsoft Excel:

  1. Select a pivot table and right-click.
  2. Select PivotTable Options.
  3. Select the Layout & Format tab.
  4. Select the For empty cells show option and specify a string.

How to Set Pivot Table Option Using Aspose.Cells for Python Excel Library

Aspose.Cells for Python via .NET provides the PivotTable.display_null_string and PivotTable.null_string properties for setting the “For empty cells show” pivot table option.

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
wb = Workbook(dataDir + "input.xlsx")
pt = wb.worksheets[0].pivot_tables[0]
# Indicating if or not display the empty cell value
pt.display_null_string = True
# Indicating the null string
pt.null_string = "null"
pt.calculate_data()
pt.refresh_data_on_opening_file = False
wb.save(dataDir + "output_out.xlsx")