Michael Hinz
How can i add a subtotal
/* get the desktop (an Xdesktop object) */
oDesktop = UNO.createDesktop()
xComponentLoader = oDesktop~{%see com.sun.star.frame.XDesktop%XDesktop}~{%see com.sun.star.frame.XComponentLoader%XComponentLoader} --get componentLoader interface
/* open a blank calc file */
url = "private:factory/scalc"
xCalcComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, .UNO~noProps)
/* get first sheet in spreadsheet */
xDocument = xCalcComponent~{%see com.sun.star.sheet.XSpreadsheetDocument%XSpreadSheetDocument}
xSheet = xDocument~getSheets~{%see com.sun.star.container.XIndexAccess%XIndexAccess}~getByIndex(0)~{%see com.sun.star.sheet.XSpreadsheet%XSpreadSheet}
/* insert value into cells */
CALL UNO.setCell xSheet, 3, 1, 100
myRange = xSheet~{%see com.sun.star.table.XCellRange%XCellRange}~getCellRangeByName("A1:C6")
/*create SubTotalDescriptor( */
xSub = myRange~{%see com.sun.star.sheet.XSubTotalCalculatable%XSubTotalCalculatable}
xSubDesc = xSub~createSubTotalDescriptor(.true)
CALL UNO.loadClass "{%see com.sun.star.sheet.SubTotalColumn}"
/*create array to set values*/
aColumn = bsf.createArray(.UNO~SubTotalColumn, 1)
aColumn[1] = .UNO~SubTotalColumn~new
aColumn[1]~Column = 3
aColumn[1]~Function = bsf.getConstant("{%see com.sun.star.sheet.GeneralFunction}","SUM")
/*apply SubTotals to range*/
xSubDesc~addNew(aColumn, 0)
xSub~applySubTotals(xSubDesc, .true)
/* insert value into cells */
CALL UNO.setCell xSheet, 3, 2, 29
::requires UNO.cls -- get UNO support