Book Image

Learn OpenOffice.org Spreadsheet Macro Programming: OOoBasic and Calc automation

By : Dr Mark Alexander Bain
Book Image

Learn OpenOffice.org Spreadsheet Macro Programming: OOoBasic and Calc automation

By: Dr Mark Alexander Bain

Overview of this book

<p>Adding macros to your spreadsheets enables you to add data processing features to your work, automate repetitive tasks, and even create complete data-driven programs that use the spreadsheet as their back end.<br /><br />This book teaches the OOoBasic language and the Calc object model, so that you can manipulate spreadsheets and data from within your programs. You will also see how to create dialog boxes and windows for friendly user interfaces, and how to integrate your spreadsheets with other applications, for example writing spreadsheet data to a document, or capturing data from a database, and using the spreadsheet for generating advanced calculations and reports.<br /><br />Calc is OpenOffice.org's spreadsheet module. Like the rest of OpenOffice.org Calc can be programmed using the built-in language OOoBasic. Both simple macros and complex applications can be developed in this language by controlling Calc through its object model. The book is compatible with the commercial version of OpenOffice.org, StarOffice, and the StarBasic language.</p>
Table of Contents (15 chapters)
Learn OpenOffice.org Spreadsheet Macro Programming
Credits
About the Author
About the Reviewer
Preface

A Real Example: Using the Table UNO to Access a Cell


We've only discussed generalities so far. Next we'll look at one of the UNOs that we'll be using on a day-to-day basis as we write macros: the table. Why look at the the table? Quite simply because that's all a worksheet is—a table. Learn to control the table and you can control the worksheet. In particular, we'll look at how the table UNO can be used to access a cell in the worksheet.

Our starting point is, of course, the OpenOffice.org website http://api.openoffice.org/docs/common/ref/com/sun/star/module-ix.html and the module com.sun.star.

From there we can follow the link to the to the table module:

From the table module web page, we can see the contents of the module:

However, at the moment we're only interested in the services:

As you can see, there are quite a number of table‑related Services, but we're only going to be looking at the CellRange service, and its XCellRange interface:

When we look on the interface page we can see...