1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Sub TablePilote
Dim document As Object, feuille As Object, zoneSource As Object, cellule As Object
Dim tables As Object, descripteur As Object, lesChamps As Object
Dim Champ1,Champ2,Champ3 As Object
document = ThisComponent
feuille = document.sheets(0)
zoneSource = feuille.getCellRangeByName("A1:A15")
tables = feuille.getDataPilotTables()
descripteur = tables.createDataPilotDescriptor()
descripteur.setSourceRange(zoneSource.RangeAddress)
lesChamps = descripteur.getDataPilotFields()
' Page :
' unChamp = lesChamps.getByIndex(x)
' unChamp.setPropertyValue("Orientation", com.sun.star.sheet.DataPilotFieldOrientation.PAGE)
' unChamp.setPropertyValue("Function", com.sun.star.sheet.GeneralFunction.NONE)
' Colonne :
'unChamp = lesChamps.getByIndex(x)
'unChamp.setPropertyValue("Orientation", com.sun.star.sheet.DataPilotFieldOrientation.COLUMN)
'unChamp.setPropertyValue("Function", com.sun.star.sheet.GeneralFunction.NONE)
' Ligne : N°Ordre
Champ1 = lesChamps.getByIndex(0)
Champ1.setPropertyValue("Orientation", com.sun.star.sheet.DataPilotFieldOrientation.ROW)
Champ1.setPropertyValue("Function", com.sun.star.sheet.GeneralFunction.NONE)
' Données : N° Ordre
Champ2 = lesChamps.getByIndex(0)
Champ2.setPropertyValue("Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA)
Champ2.setPropertyValue("Function", com.sun.star.sheet.GeneralFunction.SUM )
Champ3 = lesChamps.getByIndex(0)
Champ3.setPropertyValue("Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA)
Champ3.setPropertyValue("Function", com.sun.star.sheet.GeneralFunction.COUNT)
' cellule où est mise la table
cellule = feuille.getCellRangeByName("C1")
If tables.hasByName("pilote") then tables.removeByName("pilote")
tables.insertNewByName("pilote", cellule.CellAddress, descripteur)
End Sub |
Partager