Symphony Thursday: Developer 101 - Spreadsheets "Hello World"

February 19 2009

Symphony Thursday: Developer 101

1. Introduction to UNO Development and Documents/Writer "Hello World"
2. Spreadsheets"Hello World"

Last time, I covered the basics of UNO Development and walked you thru a "Hello World" application for Writer and Lotus Symphony Documents. This blog entry will cover an introduction to Calc and Lotus Symphony Spreadsheets.

Introduction to Lotus Symphony Spreadsheets

Just like we did with Lotus Symphony Documents, we have to call the Service Manager and the Desktop.

     Set SM=CreateObject("")
     Set Desktop=SM.createInstance("")

 Next, we need to start the Calc / Spreasheets appplication. They use a different URL to define the application, one specific for Calc / Presentations.

     Set CalcApplication = Desktop.loadComponentFromURL_("private:factory/scalc","_blank",0,args)

The command above creates the workbook and opens it for the user. We then need to get the first worksheet in the workbook.

     Set Worksheet=CalcApplication.Sheets.getByName("Sheet1")

Finally, we access the cell into which we want to enter text, numbers, or whatever.

     Set cell=Worksheet.getCellByPosition(3,6)

We have set the string in a cell, but which cell is it?

Image:Symphony Thursday: Developer 101 - Spreadsheets "Hello World"

Why did the text go into cell D7? Didn’t we write to cell (3,6)?

Rows and Columns Are Numbered from Zero

LotusScript developers will not be surprised by this, but Calc and Lotus Symphony Spreadsheets (via UNO) use Base 0. That means all arrays and indexes start at 0, not 1. So calling cell 3,6 is actually calling for cell D7. Those in the VBA world have a bit of a harder time as they are used to Base 1 everywhere.

Image:Symphony Thursday: Developer 101 - Spreadsheets "Hello World"

Just like arrays in Notes, the index starts at 0!

The Results

Image:Symphony Thursday: Developer 101 - Spreadsheets "Hello World"

Results in Lotus Symphony Spreadsheets


To try this yourself, create a new button in a Notes document in Notes 8.0.1, 8.0.2, or 8.5. 8.0.0 will not work as it does not properly register the components in the registry. With 8.0.0 or Notes 6, 6.5, or 7.X, you can use this code with 1.1.6 or higher, 2.x, or 3.x. Try it and see it work for yourself:

Dim SM As Variant
Dim Desktop As Variant
Dim CalcApplication As Variant
Dim Worksheet As Variant
Dim Cell As Variant
Dim args()
Set SM=CreateObject("")
Set Desktop=SM.createInstance("")
Set CalcApplication=Desktop.loadComponentFromURL("private:factory/scalc","_blank",0,args)
Set Worksheet=CalcApplication.Sheets.getByName("A")
Set cell=Worksheet.getCellByPosition(3,6)
Call cell.setString("Hello World!")

Next time, we will look at the basics of Lotus Symphony Presentations / Impress

0 Responses to “Symphony Thursday: Developer 101 - Spreadsheets "Hello World"”

    No Comments Found

Leave a Reply