Rijen en kolommen

From Apache OpenOffice Wiki
< NL‎ | Documentation‎ | BASIC Guide
Revision as of 12:47, 2 March 2013 by DiGro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Book.png


Elk blad bevat een lijst van zijn rijen en kolommen. Deze zijn beschikbaar via de eigenschappen Rows en Columns van het object werkbladdocument en ondersteunen de services com.sun.star.table.TableColumns en/of com.sun.star.table.TableRows.

Het volgende voorbeeld maakt twee objecten die verwijzen naar de eerste kolom en de eerste rij van een blad en slaan de verwijzingen op in de objectvariabelen EersteKolom en EersteRij.

Dim Doc As Object
Dim Blad As Object
Dim EersteRij As Object
Dim EersteKolom As Object
 
Doc = ThisComponent
Blad = Doc.Sheets(0)
 
EersteKolom = Blad.Columns(0)
EersteRij = Blad.Rows(0)

De kolomobjecten ondersteunen de service com.sun.star.table.TableColumn die de volgende eigenschappen heeft:

Width (long)
breedte va een kolom in honderdsten van een millimeter.
OptimalWidth (Boolean)
stelt een kolom in op zijn optimale breedte.
IsVisible (Boolean)
maakt een kolom zichtbaar.
IsStartOfNewPage (Boolean)
maakt, bij afdrukken, een pagina-einde vóór een kolom.

The width of a column is only optimized when the OptimalWidth property is set to True. If the width of an individual cell is changed, the width of the column that contains the cell is not changed. In terms of functionality, OptimalWidth is more of a method than a property.

The row objects are based on the com.sun.star.table.TableRow service that has the following properties:

Height (long)
height of the row in 100ths of a millimeter.
OptimalHeight (Boolean)
sets the row to its optimum height.
IsVisible (Boolean)
displays the row.
IsStartOfNewPage (Boolean)
when printing, creates a page break before the row.

If the OptimalHeight property of a row is set to the True, the row height changes automatically when the height of a cell in the row is changed. Automatic optimization continues until the row is assigned an absolute height through the Height property.

The following example activates the automatic height optimization for the first five rows in the sheet and makes the second column invisible.

Dim Doc As Object
Dim Sheet As Object
Dim Row As Object
Dim Col As Object
Dim I As Integer
 
Doc = ThisComponent
Sheet = Doc.Sheets(0)
 
For I = 0 To 4
   Row = Sheet.Rows(I)
   Row.OptimalHeight = True
Next I
 
Col = Sheet.Columns(1)
Col.IsVisible = False

Template:Documentation/Note

Documentation note.png VBA : Unlike in VBA, the first column has the index 0 and not the index 1.


Inserting and Deleting Rows and Columns

The Rows and Columns objects of a sheet can access existing rows and columns as well as insert and delete them.

Dim Doc As Object
Dim Sheet As Object
Dim NewColumn As Object
 
Doc = ThisComponent
Sheet = Doc.Sheets(0)
 
Sheet.Columns.insertByIndex(3, 1)
Sheet.Columns.removeByIndex(5, 1)

This example uses the insertByIndex method to insert a new column into the fourth column position in the sheet (index 3 - numbering starts at 0). The second parameter specifies the number of columns to be inserted (in this example: one).

The removeByIndex method deletes the sixth column (index 5). Again, the second parameter specifies the number of columns that you want to delete.

The methods for inserting and deleting rows use the Rows object function in the same way as the methods shown for editing columns using the Columns object.


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools