Difference between revisions of "NL/Documentation/BASIC Guide/Structure of Spreadsheets"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Created page with "{{DISPLAYTITLE:De structuur van werkbladdocumenten}} {{NL/Documentation/BASICGuideTOC/v2 |ShowPrevNext=block |ShowPrevPage=block |PrevPage=NL/Documentation/BASIC Guide/Spreads..." (tussenstap opslaan))
 
Line 8: Line 8:
 
}}
 
}}
 
   
 
   
Het document-object van een werkbladdocument is gebaseerd op de service<idl>com.sun.star.sheet.SpreadsheetDocument</idl>.  
+
Het document-object van een werkbladdocument is gebaseerd op de service <idl>com.sun.star.sheet.SpreadsheetDocument</idl>.  
 
Elk van deze documenten kan meerdere werkbladen bevatten. In deze gids is een tabel-gebaseerd document of werkbladdocument het gehele document, waar een werkblad (of afgekort: blad ) een werkblad (tabel) in het document is.
 
Elk van deze documenten kan meerdere werkbladen bevatten. In deze gids is een tabel-gebaseerd document of werkbladdocument het gehele document, waar een werkblad (of afgekort: blad ) een werkblad (tabel) in het document is.
  
Line 29: Line 29:
 
</source>
 
</source>
  
{{Documentation/Note|<tt>ThisComponent</tt> returns the currently active document.
+
{{Documentation/Note|<tt>ThisComponent</tt> geeft het huidige actieve document terug.
  
The expression <code>Doc.Sheets(0)</code> is a Basic simplification of the API call : <code>Doc.getSheets.getByIndex(0)</code>}}
+
De uitdrukking <code>Doc.Sheets(0)</code> is een vereenvoudiging voor BASIC van de aanroep van de API: <code>Doc.getSheets.getByIndex(0)</code>}}
  
'''Example 2: access by means of the name'''
+
'''Voorbeeld 2: toegang door middel van de naam'''
  
 
<source lang="oobas">
 
<source lang="oobas">
Line 40: Line 40:
  
 
Doc = ThisComponent
 
Doc = ThisComponent
Sheet = Doc.Sheets.getByName("Sheet 1")
+
Sheet = Doc.Sheets.getByName("Blad 1")
 
</source>
 
</source>
  
In the first example, the sheet is accessed by its number (counting begins at 0). In the second example, the sheet is accessed by its name and the <tt>getByName</tt> method.  
+
In het eerste voorbeeld wordt toegang tot het werkblad verkregen via zijn nummer (nummering begint bij 0). In het tweede voorbeeld wordt toegang tot het
 +
werkblad verkregen via zijn naam en de methode <tt>getByName</tt>.
  
The <tt>Sheet</tt> object that is obtained by the <tt>getByName</tt> method supports the <idl>com.sun.star.sheet.Spreadsheet</idl> service. In addition to providing several interfaces for editing the content, this service provides the following properties:  
+
Het object <tt>Sheet</tt> dat wordt verkregen door de methode <tt>getByName</tt> ondersteunt de service <idl>com.sun.star.sheet.Spreadsheet</idl>. In aanvulling op het verschaffen van verschillende interfaces voor het bewerken van de inhoud, verschaft deze service de volgende eigenschappen:
  
;<tt>IsVisible (Boolean)</tt>:value True if the spreadsheet is visible.
+
;<tt>IsVisible (Boolean)</tt>:waarde True als het werkblad zichtbaar is.
;<tt>PageStyle (String)</tt>:name of the page template for the spreadsheet.
+
;<tt>PageStyle (String)</tt>:naam van het opmaakprofiel voor de pagina van het werkblad.
  
=== Renaming Sheets ===
+
=== Bladen hernoemen ===
  
 
A sheet provides methods <code>getName</code> and <code>setName</code> to read and modify its name. Basic can handle both methods like a property <code>Name</code>. Here we rename the first sheet of the spreadsheet document.
 
A sheet provides methods <code>getName</code> and <code>setName</code> to read and modify its name. Basic can handle both methods like a property <code>Name</code>. Here we rename the first sheet of the spreadsheet document.

Revision as of 12:22, 2 March 2013

Book.png

Het document-object van een werkbladdocument is gebaseerd op de service com.sun.star.sheet.SpreadsheetDocument. Elk van deze documenten kan meerdere werkbladen bevatten. In deze gids is een tabel-gebaseerd document of werkbladdocument het gehele document, waar een werkblad (of afgekort: blad ) een werkblad (tabel) in het document is.

Documentation note.png VBA : Voor werkbladdocumenten en hun inhoud wordt in VBA en Apache OpenOffice BASIC een verschillende terminologie gebruikt. Waar het documentobject in VBA een Workbook wordt genoemd en de individuele pagina's Worksheets, worden zij SpreadsheetDocument en Sheet genoemd in Apache OpenOffice BASIC.


Werkbladen

U kunt de individuele werkbladen van een werkbladdocument benaderen via de lijst Sheets.

Het volgende voorbeeld toont u hoe u een werkblad kunt benaderen, ofwel via zijn nummer ofwel via zijn naam.

Voorbeeld 1: toegang door middel van het nummer (nummering begint met 0)

Dim Doc As Object
Dim Sheet As Object
 
Doc = ThisComponent
Sheet = Doc.Sheets (0)

Template:Documentation/Note

Voorbeeld 2: toegang door middel van de naam

Dim Doc As Object
Dim Sheet As Object
 
Doc = ThisComponent
Sheet = Doc.Sheets.getByName("Blad 1")

In het eerste voorbeeld wordt toegang tot het werkblad verkregen via zijn nummer (nummering begint bij 0). In het tweede voorbeeld wordt toegang tot het werkblad verkregen via zijn naam en de methode getByName.

Het object Sheet dat wordt verkregen door de methode getByName ondersteunt de service com.sun.star.sheet.Spreadsheet. In aanvulling op het verschaffen van verschillende interfaces voor het bewerken van de inhoud, verschaft deze service de volgende eigenschappen:

IsVisible (Boolean)
waarde True als het werkblad zichtbaar is.
PageStyle (String)
naam van het opmaakprofiel voor de pagina van het werkblad.

Bladen hernoemen

A sheet provides methods getName and setName to read and modify its name. Basic can handle both methods like a property Name. Here we rename the first sheet of the spreadsheet document.

Dim Doc As Object
Dim Sheet As Object
 
Doc = ThisComponent
Sheet = Doc.Sheets(0)
Sheet.Name = "First"


Creating and Deleting Sheets

The Sheets container of a spreadsheet document is also used to create and delete individual sheets. The following example uses the hasByName method to check if a sheet called MySheet exists. If it does, the method determines a corresponding object reference by using the getByName method and then saves the reference in a variable in Sheet. If the corresponding sheet does not exist, it is created by the createInstance call and inserted in the spreadsheet document by the insertByName method.

Dim Doc As Object
Dim Sheet As Object
 
Doc = ThisComponent
 
If Doc.Sheets.hasByName("MySheet") Then
   Sheet = Doc.Sheets.getByName("MySheet")
Else
   Sheet = Doc.createInstance("com.sun.star.sheet.Spreadsheet")
   Doc.Sheets.insertByName("MySheet", Sheet)
End If

The hasByName, getByName and insertByName methods are obtained from the com.sun.star.container.XNameContainer interface as described in Introduction to the API.

The interface com.sun.star.sheet.Spreadsheets provides a better method to create a new sheet: insertNewByName. It inserts a new sheet with the name specified by the first argument, at the position specified by the second argument.

Dim Doc As Object
 
Doc = ThisComponent
 
Doc.Sheets.insertNewByName("OtherSheet", 2)

The same interface provides methods moveByName and copyByName.

The com.sun.star.container.XNameContainer interface provides a method to remove a sheet of a given name:

Dim Doc As Object
 
Doc = ThisComponent
 
Doc.Sheets.removeByName("OtherSheet")


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