In der angehängten Testdatei soll mit dem Datenpiloten die Anzahl abgebildet werden. Unter OpenOffice 3.4.0 klappt das auch.
Wird das Makro unter LibreOffice in einer Version über 3.4 ausgeführt, wird leider die Summe abgebildet. Hat jemand eine Lösung dafür?
Danke für die Hilfe.
Gruß
Uwe
Code: Alles auswählen
Sub DatPilot
oDoc = ThisComponent
oSheet = oDoc.sheets.getByName("Daten")
myView = oDoc.CurrentController
' myView.setActiveSheet(oSheet)
oCellCursor = oSheet.createCursor()
oCellCursor.GotoEndOfUsedArea(True)
letzte_Zeile = oCellCursor.getRangeAddress.EndRow 'letzte Zeile suchen
oRange=oSheet.getCellRangeByPosition(0,1,40,letzte_Zeile)
ZielZelle = oDoc.sheets.getByName("DatPilot").getCellRangeByName("D9")
Ziel = ZielZelle.getCellAddress
PilotTab = oSheet.getDataPilotTables()
PilotDesc = PilotTab.createDataPilotDescriptor()
Add = oRange.getRangeAddress()
PilotDesc.setPropertyValue("IgnoreEmptyRows",1) =1
PilotDesc.setPropertyValue("ShowFilterButton",0) = 0
PilotDesc.setSourceRange(Add)
PilotDesc.ShowFilterButton = FALSE
PilotDesc.RowGrand = FALSE
PilotDesc.ColumnGrand = FALSE
PilotFelder = PilotDesc.getDataPilotFields()
PilotFeld = PilotFelder.getByIndex(2)
PilotFeld.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.COLUMN
PilotFeld = PilotFelder.getByIndex(40)
PilotFeld.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.ROW
PilotFeld = PilotFelder.getByIndex(40)
PilotFeld.Orientation = com.sun.star.sheet.DataPilotFieldOrientation.DATA
PilotFeld.Function = com.sun.star.sheet.GeneralFunction.COUNT
PilotTab.insertNewByName("DP1",Ziel,PilotDesc)
End Sub