Modifying a DataPilot Table

From Apache OpenOffice Wiki
Jump to: navigation, search

The service is used to modify an existing DataPilot table. The object for an existing table is available through the interface of the service. It implements the 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 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 = (
     UnoRuntime.queryInterface(, aDPTableObj);
 xFields = xDPDesc.getDataPilotFields();
 // add a second data field from the third column, calculating the average
 aFieldObj = xFields.getByIndex(2);
 xFieldProp = (
     UnoRuntime.queryInterface(, aFieldObj);

Documentation note.png Note how the field object for the third column is taken from the collection returned by getDataPilotFields() to create a second data field. If the field object was taken from the collection returned by getDataFields(), only the existing data field's function would be changed by the setPropertyValue() calls to that object.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages