 | OO-Snippets: Clear the selected cells of a spreadsheetCommons| Keywords | clear, delete, selected, cell, cells, spreadsheet |
|---|
| Language | ooRexx |
|---|
| Application | Calc |
|---|
| Authors | Josef Frysak (initial)
|
|---|
| Supported Versions | 2.4.1 |
|---|
| Supported OS | All |
|---|
| Question | How to clear only the selected cells of the spreadsheet?
|
|---|
| Answer | Get the selected cells by calling "getCurrentSelection" of the XModel interace. This function will return a CellCursor. Now use the CellCursors "XSheetOperation" interface to delete the 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
selection = x_Model~getCurrentSelection()
x_SheetOp = selection~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 |
|