 | OO-Snippets: Clear all cells of a spreadsheetCommons| Keywords | clear, delete, cells, cell, spreadsheet |
|---|
| Language | ooRexx |
|---|
| Application | Calc |
|---|
| Authors | Josef Frysak (initial)
|
|---|
| Supported Versions | 2.4.1 |
|---|
| Supported OS | All |
|---|
| Question | How to delete the whole spreadtsheet?
|
|---|
| Answer | Use the "XUsedAreaCursor" interface of the "SheetCellCursor" to select all cells with content. Finally use the "XSheetOperation" interface of the cursor to delete the selected cells. For further details see http://wi.wu-wien.ac.at/rgf/diplomarbeiten/BakkStuff/2008/200809_Frysak/200809_Frysak_Automating_OOo_ooRexx_Nutshells.pdf. |
|---|
x_ScriptContext = uno.getScriptContext()
if (x_ScriptContext <> .nil) then
do
x_ComponentContext = x_ScriptContext~getComponentContext
x_Desktop = x_ScriptContext~getDesktop
x_Document = x_ScriptContext~getDocument
end
else
do
x_ComponentContext = UNO.connect()
service = "com.sun.star.frame.Desktop"
s_Desktop = x_ComponentContext~getServiceManager~XMultiServiceFactory~createInstance(service)
x_Desktop = s_Desktop~XDesktop
x_Document = x_Desktop~getCurrentComponent()
end
x_Model = x_Document~XModel
s_CurrentController = x_Model~getCurrentController()
x_View = s_CurrentController~XSpreadsheetView
x_Spreadsheet = x_View~getActiveSheet()
x_SheetCellCursor = x_Spreadsheet~createCursor()
x_UsedAreaCursor = x_SheetCellCursor~XUsedAreaCursor
x_UsedAreaCursor~gotoStartOfUsedArea(.false)
x_UsedAreaCursor~gotoEndOfUsedArea(.true)
x_SheetOp = x_SheetCellCursor~XSheetOperation
x_SheetOp~clearContents(1+2+4+8+16+32+64+128+256+512)
::requires UNO.CLS
|
Changelog| Date | User | Modification |
|---|
| 2008-10-12 | 1 | Initial version |
|