oDesktop = UNO.createDesktop()
xComponentLoader = oDesktop~XDesktop~XComponentLoader
url = "private:factory/scalc"
xCalcComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, .UNO~noProps)
xDocument = xCalcComponent~XSpreadSheetDocument
xSheet = xDocument~getSheets~XIndexAccess~getByIndex(0)~XSpreadSheet
CALL UNO.setCell xSheet, 1, 0, "Name"
CALL UNO.setCell xSheet, 2, 0, "Amount"
CALL UNO.setCell xSheet, 3, 0, "Month"
CALL UNO.setCell xSheet, 1, 1, "Michael"
CALL UNO.setCell xSheet, 1, 2, "John"
CALL UNO.setCell xSheet, 1, 3, "John"
CALL UNO.setCell xSheet, 1, 4, "Michael"
CALL UNO.setCell xSheet, 1, 5, "Michael"
CALL UNO.setCell xSheet, 1, 6, "John"
CALL UNO.setCell xSheet, 1, 7, "John"
CALL UNO.setCell xSheet, 1, 8, "Michael"
CALL UNO.setCell xSheet, 2, 1, 100
CALL UNO.setCell xSheet, 2, 2, 200
CALL UNO.setCell xSheet, 2, 3, 123
CALL UNO.setCell xSheet, 2, 4, 12
CALL UNO.setCell xSheet, 2, 5, 100
CALL UNO.setCell xSheet, 2, 6, 200
CALL UNO.setCell xSheet, 2, 7, 123
CALL UNO.setCell xSheet, 2, 8, 12
CALL UNO.setCell xSheet, 3, 4, 2
CALL UNO.setCell xSheet, 3, 1, 2
CALL UNO.setCell xSheet, 3, 2, 1
CALL UNO.setCell xSheet, 3, 3, 1
CALL UNO.setCell xSheet, 3, 5, 2
CALL UNO.setCell xSheet, 3, 6, 2
CALL UNO.setCell xSheet, 3, 7, 1
CALL UNO.setCell xSheet, 3, 8, 1
xCellRange = xSheet~xCellRange~getCellRangeByName("A1:D9")
xCellRangeAddress = xCellRange~XCellRangeAddressable~getRangeAddress
xDataSupplier = xSheet~XDataPilotTablesSupplier
xData = xDataSupplier~getDataPilotTables()
xDataDescript = xData~createDataPilotDescriptor()
xDataDescript~setSourceRange(xCellRangeAddress)
myRange = xSheet~getCellByPosition(1, 10)
myAddr = myRange~XCellAddressable~getCellAddress
xFields = xDataDescript~getDataPilotFields()
aFieldObj = xFields~getByIndex(1)
aFieldObj~xPropertySet~setPropertyValue("Orientation",bsf.getConstant("com.sun.star.sheet.DataPilotFieldOrientation","COLUMN"))
aFieldObj = xFields~getByIndex(3)
aFieldObj~xPropertySet~setPropertyValue("Orientation",bsf.getConstant("com.sun.star.sheet.DataPilotFieldOrientation","ROW"))
aFieldObj = xFields~getByIndex(2)
aFieldObj~xPropertySet~setPropertyValue("Orientation", bsf.getConstant("com.sun.star.sheet.DataPilotFieldOrientation","DATA"))
aFieldObj~xPropertySet~setPropertyValue("Function", bsf.getConstant("com.sun.star.sheet.GeneralFunction", "SUM"))
xData~insertNewByName("DataPilotExample", myAddr, xDataDescript)
::requires UNO.CLS