21.08.2013 Views

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

OpenOffice.org BASIC Guide.pdf - OpenOffice.org wiki

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

More Than Just Text 112<br />

Cols = Table.getColumns<br />

For RowIndex = 1 To Rows.getCount()<br />

For ColIndex = 1 To Cols.getCount()<br />

CellName = Chr(Asc("A") - 1 + ColIndex) & RowIndex<br />

Cell = Table.getCellByName(CellName)<br />

Cell.String = "row: " & CStr(RowIndex) + ", column: " &<br />

CStr(ColIndex)<br />

Next<br />

Next<br />

A table cell is comparable with a standard text. It supports the createTextCursor interface<br />

for creating an associated TextCursor object.<br />

CellCursor = Cell.createTextCursor()<br />

All formatting options for individual characters and paragraphs are therefore automatically<br />

available.<br />

The following example searches through all tables of a text document and applies the<br />

right-align format to all cells with numerical values by means of the corresponding<br />

paragraph property.<br />

Dim Doc As Object<br />

Dim TextTables As Object<br />

Dim Table As Object<br />

Dim CellNames<br />

Dim Cell As Object<br />

Dim CellCursor As Object<br />

Dim I As Integer<br />

Dim J As Integer<br />

Doc = StarDesktop.CurrentComponent<br />

TextTables = Doc.getTextTables()<br />

For I = 0 to TextTables.count - 1<br />

Table = TextTables(I)<br />

CellNames = Table.getCellNames()<br />

For J = 0 to UBound(CellNames)<br />

Cell = Table.getCellByName(CellNames(J))<br />

If IsNumeric(Cell.String) Then<br />

CellCursor = Cell.createTextCursor()<br />

CellCursor.paraAdjust =<br />

com.sun.star.style.ParagraphAdjust.RIGHT<br />

End If

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

Saved successfully!

Ooh no, something went wrong!