Michael Hinz
How to copy a sheet
/* get the dsktop (an Xdesctop object) */
oDesktop = UNO.createDesktop()
xComponentLoader = oDesktop~{%see com.sun.star.frame.XDesktop%XDesktop}~{%see com.sun.star.frame.XComponentLoader%XComponentLoader} -- get componentLoader interface
/* open the file: test.ods */
url = ConvertToURL(directory()"/test.ods")
xCalcComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, .UNO~noProps)
/* get sheet „Rexx“ in spreadsheet */
xDocument = xCalcComponent~{%see com.sun.star.sheet.XSpreadsheetDocument%XSpreadSheetDocument}
xSheet = xDocument~getSheets~{%see com.sun.star.container.XNameAccess%XNameAccess}~getByName("Rexx")~{%see com.sun.star.sheet.XSpreadsheet%XSpreadSheet}
/* insert values into cells */
CALL UNO.setCell xSheet, 0, 0, "This sheet will be copied"
CALL UNO.setCell xSheet, 0, 1, "333"
CALL UNO.setCell xSheet, 0, 2, "222"
CALL UNO.setCell xSheet, 0, 3, "111"
CALL syssleep 3
/* copy sheet */
xSheets = xDocument~getSheets()
xSheets~copyByName("Rexx", "rexx2", 2)
/* set focus on new sheet */
xFocusSheet = xDocument~getSheets~{%see com.sun.star.container.XNameAccess%XNameAccess}~getByName("rexx2")~{%see com.sun.star.sheet.XSpreadsheet%XSpreadSheet}
xController = xDocument~{%see com.sun.star.frame.XModel%XModel}~getCurrentController
xSpreadsheetView = xController~{%see com.sun.star.sheet.XSpreadsheetView%xSpreadsheetView}~setActiveSheet(xFocusSheet)
::requires UNO.cls -- get UNO support