Difference between revisions of "Data pilots"
(remove from Category:Tutorials if in Category:Basic:Tutorials) |
|||
Line 39: | Line 39: | ||
[[Category:Basic:Tutorials]] | [[Category:Basic:Tutorials]] | ||
+ | [[Category:Calc]] | ||
+ | [[Category:API]] |
Revision as of 18:59, 12 June 2007
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
[oobas]
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:
[oobas]
oDoc = thisComponent
oCurSelection = oDoc.CurrentSelection
oSheet = oDoc.CurrentController.ActiveSheet
oCursor = oSheet.createCursorbyRange(oCurSelection)
oDataPilot = fnCurDataPilot(oCursor)
Delete datapilot
[oobas]
sub subDeleteDataPilot(oDoc, oDataPilot)
oDoc.getsheets.getByIndex(oDataPilot.getOutputRange.sheet).getDataPilotTables.removeByName(oDataPilot.Name)
end sub