 | OO-Snippets: access cellsCommons| Keywords | Calc, cells, spreadsheet, access, XSheet, getCellByPosition, XNAmeAccess, getByName, XCell, getValue, getString, getString, getFormula, setValue, setString, setFormula |
|---|
| Language | OOBasic |
|---|
| Application | Calc |
|---|
| Authors | Sasa Kelecevic (initial)
Andrew Pitonyak (initial)
Laurent Godard (initial)
Michael Hoennig (initial)
Tom Schindl
|
|---|
| Supported Versions | |
|---|
| Supported OS | |
|---|
| Question |
How can the cells of a given OOo/Calc document be accessed?
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
Set objDesktop =
objServiceManager.createInstance("com.sun.star.frame.Desktop")
Dim args()
Set objCalcDocument =
objDesktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, args)
Set objSheets = objCalcDocument.Sheets
aCell=???
|
|
|---|
| Answer |
Cells can be accessed via the sheet in which they are:
objSheets.getByName("TheSheetName").
|
|---|
Sub ExampleGetValue
Dim oDocument As Object, oSheet As Object, oCell As Object
oDocument=ThisComponent
oSheet=oDocument.Sheets.getByName("Sheet1")
oCell=oSheet.getCellByPosition(0,0)
print oCell.getValue
End sub
Sub ExampleSetValue
Dim oDocument As Object, oSheet As Object, oCell As Object
oDocument=ThisComponent
oSheet=oDocument.Sheets.getByName("Sheet1")
oCell=oSheet.getCellByPosition(0,0)
oCell.setValue(23658)
End Sub
|
Changelog| Date | User | Modification |
|---|
| 2004-06-22 | tomsontom | Modified to match new snippet-DTD | | 0000-00-00 | sasa | Intial release |
|