Michael Hinz
How can i add a scenario
/* 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}
/*create cell range, get address and set into array*/
xCellRange = xSheet~{%see com.sun.star.table.XCellRange%xCellRange}~getCellRangeByName("B3:F6")
xCellRangeAddress = xCellRange~{%see com.sun.star.sheet.XCellRangeAddressable%XCellRangeAddressable}~getRangeAddress
CALL UNO.loadClass "{%see com.sun.star.table.CellRangeAddress}"
oAddr = bsf.createArray(.UNO~CellRangeAddress, 1)
oAddr[1] = xCellRangeAddress
aScenarioName = rexx
aScenarioComment = mein scenario
/* get scenario and apply to cell range*/
xScenSupplier = xSheet~{%see com.sun.star.sheet.XScenariosSupplier%XScenariosSupplier}
xScenarios = xScenSupplier~getScenarios
xScenarios~addNewByName(aScenarioName, oAddr, aScenarioComment)
::requires UNO.CLS -- get UNO support