21.08.2013 Views

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The Structure of Spreadsheets<br />

COLUMNS<br />

the columns after the insert position are moved to the left.<br />

The XRangeMovement interface provides two additional methods for moving (moveRange) or copying<br />

(copyRange) cell ranges. The following example moves the B2:C3 range so that the range starts at position A6:<br />

Dim Doc As Object<br />

Dim Sheet As Object<br />

Dim CellRangeAddress As New com.sun.star.table.CellRangeAddress<br />

Dim CellAddress As New com.sun.star.table.CellAddress<br />

Doc = ThisComponent<br />

Sheet = Doc.Sheets(0)<br />

CellRangeAddress.Sheet = 0<br />

CellRangeAddress.StartColumn = 1<br />

CellRangeAddress.StartRow = 1<br />

CellRangeAddress.EndColumn = 2<br />

CellRangeAddress.EndRow = 2<br />

CellAddress.Sheet = 0<br />

CellAddress.Column = 0<br />

CellAddress.Row = 5<br />

Sheet.moveRange(CellAddress, CellRangeAddress)<br />

In addition to the CellRangeAdress structure, the moveRange method expects a com.sun.star.table.CellAddress<br />

structure to define the origin of the move's target region. The CellAddress method provides the following<br />

values:<br />

Sheet (short)<br />

number of the spreadsheet (numbering begins with 0).<br />

Column (long)<br />

number of the addressed column (numbering begins with 0).<br />

Row (long)<br />

number of the addressed row (numbering begins with 0).<br />

The cell contents in the target range are always overwritten by the moveRange method. Unlike in the<br />

InsertCells method , a parameter for performing automatic moves is not provided in the removeRange<br />

method.<br />

The copyRange method functions in the same way as the moveRange method, except that copyRange inserts a<br />

copy of the cell range instead of moving it.<br />

Note – VBA : In terms of their function, the <strong>OpenOffice</strong>.<strong>org</strong> Basic insertCell, removeRange, and<br />

copyRange methods are comparable with the VBA Range.Insert, Range.Delete ,and Range.Copy methods.<br />

Whereas in VBA, the methods are applied to the corresponding Range object, in <strong>OpenOffice</strong>.<strong>org</strong> Basic they are<br />

applied to the associated Sheet object.<br />

Formatting Spreadsheet Documents<br />

A spreadsheet document provides properties and methods for formatting cells and pages.<br />

Cell Properties<br />

There are numerous options for formatting cells, such as specifying the font type and size for text. Each cell<br />

supports the com.sun.star.style.CharacterProperties and com.sun.star.style.ParagraphProperties services, the main<br />

properties of which are described in Text Documents. Special cell formatting is handled by the<br />

com.sun.star.table.CellProperties service. The main properties of this service are described in the following<br />

sections.<br />

98 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!