Apache OpenOffice (AOO) Bugzilla – Issue 42199
Datapilot with external datasource not accessible via API
Last modified: 2017-05-20 09:31:58 UTC
I was not able to access the datapilot tables created with external datasource thru the API. Once I create the datapilot there is no way with which I can access it thru the APIs that are currently available. Thanks, Dinesh
*** Issue 42199 has been confirmed by votes. ***
You mean that something like (oSheet is the Spreadsheet that is supposed to contain your DataPilotTable) XDataPilotTablesSupplier DPTS = (XDataPilotTablesSupplier) UnoRuntime.queryInterface(XDataPilotTablesSupplier.class, oSheet); XDataPilotTables DPT = DPTS.getDataPilotTables(); returns you a container of DataPilotTables that doesn't contain yours ? Do you have a sample for this ?
ofcourse. I am using the same code template.But it is not working for external datasource. Even in the developer documentation it says "Only DataPilot tables that are based on cell data are supported by these services. DataPilot tables created directly from external data sources or using the com.sun.star.sheet.DataPilotSource service cannot be created or modified this way." That's why I filed it as an enchancement request. I even see lot of people asking for it in the newsgroups. Thanks, Dinesh
sw->nn: looks like one for you then
Enhancement for a later version. This won't make it into 2.0.
Can you atleast let me know the module, so that I can look into it and try to fix the bug.
taking the issue
Fixed in CWS "datapilotapi". The following Basic macro creates a DataPilot table based on the Bibliography database: Sub InsertDatabaseTable oTables = ThisComponent.Sheets(0).DataPilotTables oDescriptor = oTables.createDataPilotDescriptor dim aImpDesc(0 to 2) as new com.sun.star.beans.PropertyValue aImpDesc(0).Name = "DatabaseName" aImpDesc(0).Value = "Bibliography" aImpDesc(1).Name = "SourceType" aImpDesc(1).Value = com.sun.star.sheet.DataImportMode.TABLE aImpDesc(2).Name = "SourceObject" aImpDesc(2).Value = "biblio" oDescriptor.ImportDescriptor = aImpDesc() oFields = oDescriptor.DataPilotFields oFields.getByName("Author").Orientation = _ com.sun.star.sheet.DataPilotFieldOrientation.ROW oFields.getByName("Year").Orientation = _ com.sun.star.sheet.DataPilotFieldOrientation.COLUMN oDataField = oFields.getByName("ISBN") oDataField.Orientation = _ com.sun.star.sheet.DataPilotFieldOrientation.DATA oDataField.Function = com.sun.star.sheet.GeneralFunction.COUNT dim aOutPos as new com.sun.star.table.CellAddress aOutPos.Column = 1 aOutPos.Row = 5 aOutPos.Sheet = 0 oTables.insertNewByName("MyTable1", aOutPos, oDescriptor) End Sub If the DataPilotSource example from the DevGuide is registered, this macro creates a DataPilot table based on it: Sub InsertServiceTable oTables = ThisComponent.Sheets(0).DataPilotTables oDescriptor = oTables.createDataPilotDescriptor oDescriptor.SourceServiceName = "ExampleDataPilotSource" oFields = oDescriptor.DataPilotFields oFields.getByName("ones").Orientation = _ com.sun.star.sheet.DataPilotFieldOrientation.COLUMN oFields.getByName("tens").Orientation = _ com.sun.star.sheet.DataPilotFieldOrientation.ROW oFields.getByName("value").Orientation = _ com.sun.star.sheet.DataPilotFieldOrientation.DATA dim aOutPos as new com.sun.star.table.CellAddress aOutPos.Column = 1 aOutPos.Row = 5 aOutPos.Sheet = 0 oTables.insertNewByName("MyTable2", aOutPos, oDescriptor) End Sub
reassigning to QA for verification
verified