Classic PivotTable Layout Display

Hi, can you help me how to change the pivot display to “Classic PivotTable layout (enables dragging of fields in the grid)” using Python via Java, thanks.

Sample.zip (9.3 KB)
image.png (36.1 KB)

Also how to use the dropzone codes PivotOptions - Aspose.Cells for Python via Java - API Reference using Python via Java, so I can fully replicate the Classic PivotTable Layout which enables dragging items into it.

@myDAN
You can use the PivotTable.setGridDropZones method to control “Classic PivotTable layout (enables dragging of fields in the grid)” option.
The sample code using Python via Java as follows:

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook, CellsHelper, SaveFormat, PdfSaveOptions, PivotFieldType, PivotTableStyleType

print(CellsHelper.getVersion())
workbook = Workbook("Sample.xlsx")

wsPivot = workbook.getWorksheets().get(0)
pivots = wsPivot.getPivotTables()
pivot = pivots.get(0)

#change the status
pivot.setGridDropZones(False)

pivot.setRefreshDataFlag(True)
pivot.refreshData();
pivot.calculateData();
pivot.setRefreshDataFlag(False)
workbook.save("Sample_out.xlsx")

jpype.shutdownJVM() 

Regarding PivotOptions, it belongs to Chart. When using the data source in PivotTable to create a Chart, a Pivot Chart will be generated. You can obtain the PivotOptions object through the Chart.getPivotOptions() method and set property values .

1 Like

Thank you @John.He the setGridDropZones did the trick

@myDAN
You are welcome. If you have any questions, please feel free to contact us.

1 Like