Data pilots
From Apache OpenOffice Wiki
The last I looked it was not possible to access a DataPilot based on external data via the API - so these routines are for DataPilots based on data within the spreadsheet.
Current data pilot
Function fnCurDataPilot(oCursor as object) as object 'Returns the first data pilot that intersects with oCursor 'If no data pilot intersects it returns null dim oEnum as object, oDP as object oEnum = thisComponent.getCurrentController.getActiveSheet.getDataPilotTables.createEnumeration While oEnum.hasMoreElements() oDP = oEnum.nextElement() if oCursor.queryIntersection(oDP.outputRange).getCount > 0 then fnCurDataPilot = oDp exit function end if wend 'fnCurDataPilot = null end function
Example of calling the above function:
oDoc = thisComponent oCurSelection = oDoc.CurrentSelection oSheet = oDoc.CurrentController.ActiveSheet oCursor = oSheet.createCursorbyRange(oCurSelection) oDataPilot = fnCurDataPilot(oCursor)
Delete datapilot
sub subDeleteDataPilot(oDoc, oDataPilot) oDoc.getsheets.getByIndex(oDataPilot.getOutputRange.sheet).getDataPilotTables.removeByName(oDataPilot.Name) end sub