Difference between revisions of "Data pilots"
From Apache OpenOffice Wiki
Line 2: | Line 2: | ||
=Current data pilot= | =Current data pilot= | ||
− | < | + | <source lang="oobas"> |
Function fnCurDataPilot(oCursor as object) as object | Function fnCurDataPilot(oCursor as object) as object | ||
Line 20: | Line 20: | ||
'fnCurDataPilot = null | 'fnCurDataPilot = null | ||
end function | end function | ||
− | </ | + | </source> |
Example of calling the above function: | Example of calling the above function: | ||
− | < | + | <source lang="oobas"> |
oDoc = thisComponent | oDoc = thisComponent | ||
oCurSelection = oDoc.CurrentSelection | oCurSelection = oDoc.CurrentSelection | ||
Line 29: | Line 29: | ||
oCursor = oSheet.createCursorbyRange(oCurSelection) | oCursor = oSheet.createCursorbyRange(oCurSelection) | ||
oDataPilot = fnCurDataPilot(oCursor) | oDataPilot = fnCurDataPilot(oCursor) | ||
− | </ | + | </source> |
=Delete datapilot= | =Delete datapilot= | ||
− | < | + | <source lang="oobas"> |
sub subDeleteDataPilot(oDoc, oDataPilot) | sub subDeleteDataPilot(oDoc, oDataPilot) | ||
oDoc.getsheets.getByIndex(oDataPilot.getOutputRange.sheet).getDataPilotTables.removeByName(oDataPilot.Name) | oDoc.getsheets.getByIndex(oDataPilot.getOutputRange.sheet).getDataPilotTables.removeByName(oDataPilot.Name) | ||
end sub | end sub | ||
− | </ | + | </source> |
[[Category:Basic:Tutorials]] | [[Category:Basic:Tutorials]] | ||
[[Category:Calc]] | [[Category:Calc]] | ||
[[Category:API]] | [[Category:API]] |
Revision as of 17:53, 10 July 2008
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