Pivot table column display as "% of total"

Creating a macro - Writing a Script - Using the API

Pivot table column display as "% of total"

Postby bdonauba » Mon Jul 31, 2017 9:44 am

I try to create a pivot table with columns that shout be displayed as "percent of total". I thought it is as easy as creating a DataPilotFieldReference Object set the members to the wanted values - in my case TOTAL_PERCENTAGE and "Auftrag" - and assign this object to the DataPilotField.reference member, but this doesn't do the trick. I get an extra column with "count of auftrag" but the values are not displayed as percent. If I look at the field description in the layout dialogue or with the debugger of the basic ide my settings are gone. ReferenceType is 0 and ReferenceField is "".

Code: Select all   Expand viewCollapse view
    dim fieldABNummerPercent
    'fieldABNummerPercent = Fields.getByIndex(0)
    fieldABNummerPercent =Fields.getByName("Auftrag")
    fieldABNummerPercent.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.DATA
    fieldABNummerPercent.Function = com.sun.star.sheet.GeneralFunction.COUNT
    dim reference as new com.sun.star.sheet.DataPilotFieldReference
    fieldABNummerPercent.reference = reference
    reference.ReferenceType=com.sun.star.sheet.DataPilotFieldReferenceType.TOTAL_PERCENTAGE '7
    fieldABNummerPercent.setName("gesamt %")
Posts: 6
Joined: Fri Jan 18, 2008 11:36 am

Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 9 guests