Difference between revisions of "Documentation/DevGuide/Spreadsheets/Modifying a DataPilot Table"
m |
|||
Line 14: | Line 14: | ||
The following example modifies the table from the previous example to contain a second data field using the same source column as the existing data field, but using the "average" function instead. | The following example modifies the table from the previous example to contain a second data field using the same source column as the existing data field, but using the "average" function instead. | ||
<!--[SOURCE:Spreadsheet/SpreadsheetSample.java]--> | <!--[SOURCE:Spreadsheet/SpreadsheetSample.java]--> | ||
− | + | <syntaxhighlight lang="java"> | |
// --- Modify the DataPilot table --- | // --- Modify the DataPilot table --- | ||
Object aDPTableObj = xDPTables.getByName("DataPilotExample"); | Object aDPTableObj = xDPTables.getByName("DataPilotExample"); | ||
Line 26: | Line 26: | ||
UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, aFieldObj); | UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, aFieldObj); | ||
xFieldProp.setPropertyValue("Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA); | xFieldProp.setPropertyValue("Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA); | ||
− | xFieldProp.setPropertyValue("Function", com.sun.star.sheet.GeneralFunction.AVERAGE); | + | xFieldProp.setPropertyValue("Function", com.sun.star.sheet.GeneralFunction.AVERAGE);</syntaxhighlight> |
Latest revision as of 13:33, 20 December 2020
The com.sun.star.sheet.DataPilotTable service is used to modify an existing DataPilot table. The object for an existing table is available through the com.sun.star.container.XNameAccess interface of the com.sun.star.sheet.DataPilotTables service. It implements the com.sun.star.sheet.XDataPilotDescriptor interface, so that the DataPilot table can be modified in the same manner as the descriptor for a new table in the preceding section. After any change to a DataPilot table's settings, the table is automatically recalculated.
Additionally, the com.sun.star.sheet.XDataPilotTable interface offers a getOutputRange()
method that is used to find which range on the spreadsheet the table occupies, and a refresh()
method that recalculates the table without changing any settings.
The following example modifies the table from the previous example to contain a second data field using the same source column as the existing data field, but using the "average" function instead.
// --- Modify the DataPilot table --- Object aDPTableObj = xDPTables.getByName("DataPilotExample"); xDPDesc = (com.sun.star.sheet.XDataPilotDescriptor) UnoRuntime.queryInterface(com.sun.star.sheet.XDataPilotDescriptor.class, aDPTableObj); xFields = xDPDesc.getDataPilotFields(); // add a second data field from the third column, calculating the average aFieldObj = xFields.getByIndex(2); xFieldProp = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class, aFieldObj); xFieldProp.setPropertyValue("Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA); xFieldProp.setPropertyValue("Function", com.sun.star.sheet.GeneralFunction.AVERAGE);
Content on this page is licensed under the Public Documentation License (PDL). |