OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Editing Spreadsheet Documents<br />
Doc = ThisComponent<br />
Sheet = Doc.Sheets.getByName("Sheet 1")<br />
CellRange = Sheet.getCellRangeByPosition(0, 0, 2, 14)<br />
The arguments of getCellRangeByPosition are the position of the upper left cell of the range, followed by<br />
the position of the bottom right cell of the same range.<br />
The location of individual cells in a cell range can be determined using the getCellByPosition method, where<br />
the coordinates of the top left cell in the cell range is (0, 0). The following example uses this method to create an<br />
object of cell C3.<br />
Dim Doc As Object<br />
Dim Sheet As Object<br />
Dim CellRange As Object<br />
Dim Cell As Object<br />
Doc = ThisComponent<br />
Sheet = Doc.Sheets.getByName("Sheet 1")<br />
CellRange = Sheet.getCellRangeByName("B2:D4")<br />
Cell = CellRange.GetCellByPosition(1, 1)<br />
Formatting Cell Ranges<br />
Just like individual cells, you can apply formatting to cell ranges using the com.sun.star.table.CellProperties<br />
service. For more information and examples of this service, see Formatting Spreadsheet Documents.<br />
Computing With Cell Ranges<br />
You can use the computeFunction method to perform mathematical operations on cell ranges. The<br />
computeFunction expects a constant as the parameter that describes the mathematical function that you want to<br />
use. The associated constants are defined in the com.sun.star.sheet.GeneralFunction enumeration. The following<br />
values are available:<br />
SUM<br />
COUNT<br />
COUNTNUMS<br />
AVERAGE<br />
MAX<br />
MIN<br />
PRODUCT<br />
STDEV<br />
VAR<br />
STDEVP<br />
sum of all numerical values<br />
total number of all values (including non-numerical values)<br />
total number of all numerical values<br />
average of all numerical values<br />
largest numerical value<br />
smallest numerical value<br />
product of all numerical values<br />
standard deviation<br />
variance<br />
standard deviation based on the total population<br />
108 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010