Werkbladdocumenten opmaken

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

Jump to: navigation, search
Book.png


Een werkbladdocument verschaft eigenschappen en methoden voor het opmaken van cellen en pagina's.

Celeigenschappen

Er zijn vele opties voor het opmaken van cellen, zoals het specificeren van het lettertype en afmeting voor tekst. Elke cel ondersteunt de services com.sun.star.style.CharacterProperties en com.sun.star.style.ParagraphProperties, waarvan de belangrijkste eigenschappen werden beschreven in Tekstdocumenten. Speciale celopmaak wordt behandeld door de service com.sun.star.table.CellProperties. De belangrijkste eigenschappen voor deze service worden beschreven in de volgende gedeelten.

U kunt alle genoemde eigenschappen toepassen op individuele cellen en ook op celbereiken.

Documentation note.png VBA : Het object CellProperties in de API van Apache OpenOffice is vergelijkbaar met het object Interior uit VBA dat ook specifieke eigenschappen voor cellen definieert.


Achtergrondkleur en schaduw

De service com.sun.star.table.CellProperties verschaft de volgende eigenschappen voor het definiëren van achtergrondkleuren en schaduw:

CellBackColor (Long)
achtergrondkleur van de tabelcel
IsCellBackgroundTransparent (Boolean)
stelt de achtergrondkleur op transparant in
ShadowFormat (struct)
specificeert de schaduw voor cellen (structuur die overeenkomt met com.sun.star.table.ShadowFormat)

De structuur com.sun.star.table.ShadowFormat en de gedetailleerde specificaties voor de schaduw voor cellen hebben de volgende structuur:

Location (enum)
positie van de schaduw (waarde van de structuur com.sun.star.table.ShadowLocation).
ShadowWidth (Short)
grootte van de schaduw in 100-en van een millimeter
IsTransparent (Boolean)
stelt de schaduw in op transparant
Color (Long)
kleur van de schaduw

Het volgende voorbeeld schrijft het getal 1000 in de cel B2, verandert de achtergrondkleur naar rood met behulp van de eigenschap CellBackColor en maakt dan voor de cel een lichtgrijze schaduw welke 1 mm naar links en naar beneden verplaatst wordt.

Dim Doc As Object
Dim Blad As Object
Dim Cel As Object
Dim SchaduwOpmaak As New com.sun.star.table.ShadowFormat
 
Doc = ThisComponent
Blad = Doc.Sheets(0)
Cel = Blad.getCellByPosition(1,1)
 
Cel.Value = 1000
 
Cel.CellBackColor = RGB(255, 0, 0)
 
SchaduwOpmaak.Location = com.sun.star.table.ShadowLocation.BOTTOM_RIGHT
SchaduwOpmaak.ShadowWidth = 100
SchaduwOpmaak.Color = RGB(160, 160, 160)
 
Cel.ShadowFormat = SchaduwOpmaak

Uitlijnen

Apache OpenOffice verschaft verschillende functies die u toestaan de uitlijning van een tekst in een tabel te veranderen.

De volgende eigenschappen definiëren de horizontale en verticale uitlijning van een tekst:

HoriJustify (enum)
horizontale uitlijning van de tekst (waarde uit com.sun.star.table.CellHoriJustify)
VertJustify (enum)
verticale uitlijning van de tekst (waarde uit com.sun.star.table.CellVertJustify)
Orientation (enum)
richting van de tekst (waarde die overeenkomt met com.sun.star.table.CellOrientation)
IsTextWrapped (Boolean)
staat automatische regeleinden binnen de cel toe
RotateAngle (Long)
draaihoek van de tekst in 100-en van een graad

Het volgende voorbeeld toont hoe u de inhoud van een cel kunt “stapelen” zodat de individuele tekens onder elkaar worden afgedrukt in de linkerbovenhoek van de cel. De tekens worden niet gedraaid.

Dim Doc As Object
Dim Blad As Object
Dim Cel As Object
 
Doc = ThisComponent
Blad = Doc.Sheets(0)
Cel = Blad.getCellByPosition(1,1)
 
Cel.Value = 1000
 
Cel.HoriJustify = com.sun.star.table.CellHoriJustify.LEFT
Cel.VertJustify = com.sun.star.table.CellVertJustify.TOP
Cel.Orientation = com.sun.star.table.CellOrientation.STACKED

Opmaken van getallen, datum en tekst

Apache OpenOffice verschaft een heel bereik aan voorgedefinieerde datum en tijd-opmaken. Elk van deze opmaken heeft een intern getal dat wordt gebruikt om de opmaak toe te wijzen aan cellen met behulp van de eigenschap NumberFormat. Apache OpenOffice verschaft de methoden queryKey en addNew zodat u bestaande opmaak voor getallen kunt benaderen en ook uw eigen opmaak voor getallen kunt maken. De methoden worden benaderd via de volgende aanroep voor het object:

NumberFormats = Doc.NumberFormats

Een opmaak wordt gespecificeerd met behulp van een tekenreeks voor opmaak die is gestructureerd op eenzelfde wijze als de functie voor opmaak van Apache OpenOffice BASIC. Er is echter één groot verschil: waar de opmaak via opdrachten Engelse afkortingen verwacht en decimale punten of tekens als scheidingsteken voor duizendtallen, moeten land-specifieke afkortingen worden gebruikt voor de structuur van een opmaak via opdrachten voor het object NumberFormats.

Het volgende voorbeeld maakt de B2 cel op zodat getallen worden weergegeven met drie decimale plaatsen en komma's gebruikt als scheidingsteken voor duizendtallen.

Dim Doc As Object
Dim Blad As Object
Dim Cel As Object
Dim GetalOpmaak As Object
Dim GetalOpmaakTekens As String
Dim NummerOpmaakId As Long
Dim LocaleInstellingen As New com.sun.star.lang.Locale
 
Doc = ThisComponent
Blad = Doc.Sheets(0)
Cel = Blad.getCellByPosition(1,1)
 
Cel.Value = 23400.3523565
 
LocaleInstellingen.Language = "en"
LocaleInstellingen.Country = "us"
 
GetalOpmaak = Doc.NumberFormats
GetalOpmaakTekens = "#,##0.000"
 
GetalOpmaakId = GetalOpmaak.queryKey(GetalOpmaakTekens, LocaleInstellingen, True)
If GetalOpmaakId = -1 Then
   GetalOpmaakId = GetalOpmaak.addNew(GetalOpmaakTekens, LocaleInstellingen)
End If
 
MsgBox GetalOpmaakId
Cel.NumberFormats = GetalOpmaakId

Het dialoogvenster Cellen opmaken in Apache OpenOffice Calc verschaft een overzicht van de verschillende opties voor opmaak van cellen.

Eigenschappen voor pagina's

Eigenschappen voor pagina's zijn de opties voor opmaak die de inhoud van het document op een pagina plaatsen, net zoals de visuele elementen die pagina na pagina herhaald worden. Hierbij horen

  • Indeling van het papier
  • Paginamarges
  • Kop- en voetteksten.

De procedure voor het definiëren van opmaak van de pagina verschilt van andere vormen van opmaak. Waar dat bij cel, alinea, en teken-elementen direct kan, kan opmaak voor de pagina ook worden gedefinieerd en indirect worden toegepast met behulp van pagina-opmaakprofielen. Kop- en voetteksten worden bijvoorbeeld toegevoegd aan het pagina-opmaakprofiel.

De volgende gedeelten beschrijven de belangrijkste opties voor opmaak van pagina's van werkbladen. Veel van de opmaakprofielen die worden beschreven zijn ook beschikbaar voor tekstdocumenten. De eigenschappen voor pagina's die geldig zijn voor beide typen van documenten worden gedefinieerd in de service com.sun.star.style.PageProperties. De eigenschappen voor pagina's die alleen kunnen worden toegepast op werkbladdocumenten worden gedefinieerd in de service com.sun.star.sheet.TablePageStyle.

Documentation note.png VBA : De eigenschappen voor pagina's (paginamarges, randen enzovoort) voor een document in Microsoft Office worden gedefinieerd door middel van een object PageSetup op het niveau van het object Worksheet (Excel) of het object Document (Word). In Apache OpenOffice worden deze eigenschappen gedefinieerd met behulp van een pagina-opmaakprofiel dat op zijn beurt wordt gekoppeld aan het geassocieerde document.


Achtergrond van pagina

De service com.sun.star.style.PageProperties definieert de volgende eigenschappen van een achtergrond van een pagina:

BackColor (long)
kleur van de achtergrond
BackGraphicURL (String)
URL van de afbeelding voor de achtergrond die u wilt gebruiken
BackGraphicFilter (String)
naam van het filter voor het interpreteren van de afbeelding voor de achtergrond
BackGraphicLocation (Enum)
positie van de afbeelding voor de achtergrond (waarde overeenkomstig de nummering)
BackTransparent (Boolean)
maakt de achtergrond transparant

Opmaak van de pagina

De opmaak van de pagina wordt gedefinieerd met behulp van de volgende eigenschappen van de service com.sun.star.style.PageProperties

IsLandscape (Boolean)
indeling Liggend
Width (long)
breedte van de pagina in 100-en van een millimeter
Height (long)
hoogte van de pagina in 100-en van een millimeter
PrinterPaperTray (String)
naam van de papierlade van de printer die u wilt gebruiken

Het volgende voorbeeld stelt de opmaak van de pagina van het paginaopmaakprofiel “Standaard” in op de indeling DIN A5 liggend (hoogte 14.8 cm, breedte 21 cm):

Dim Doc As Object
Dim Blad As Object
Dim Opmaakprofielen As Object 
Dim PaginaOpmaakprofielen As Object
Dim DefPagina As Object
 
Doc = ThisComponent
Opmaakprofielen = Doc.StyleFamilies
PaginaOpmaakprofielen = Opmaakprofielen.getByName("PageStyles")
DefPagina = PaginaOpmaakprofielen.getByName("Default")
 
DefPagina.IsLandscape = True
DefPagina.Width = 21000
DefPagina.Height = 14800

Paginamarge, rand en schaduw

The com.sun.star.style.PageProperties service provides the following properties for adjusting page margins as well as borders and shadows:

LeftMargin (long)
width of the left hand page margin in hundredths of a millimeter
RightMargin (long)
width of the right hand page margin in hundredths of a millimeter
TopMargin (long)
width of the top page margin in hundredths of a millimeter
BottomMargin (long)
width of the bottom page margin in hundredths of a millimeter
LeftBorder (struct)
specifications for left-hand line of page border (com.sun.star.table.BorderLine structure)
RightBorder (struct)
specifications for right-hand line of page border (com.sun.star.table.BorderLine structure)
TopBorder (struct)
specifications for top line of page border (com.sun.star.table.BorderLine structure)
BottomBorder (struct)
specifications for bottom line of page border (com.sun.star.table.BorderLine structure)
LeftBorderDistance (long)
distance between left-hand page border and page content in hundredths of a millimeter
RightBorderDistance (long)
distance between right-hand page border and page content in hundredths of a millimeter
TopBorderDistance (long)
distance between top page border and page content in hundredths of a millimeter
BottomBorderDistance (long)
distance between bottom page border and page content in hundredths of a millimeter
ShadowFormat (struct)
specifications for shadow of content area of page (com.sun.star.table.ShadowFormat structure)

The following example sets the left and right-hand borders of the "Default" page style to 1 centimeter.

Dim Doc As Object
Dim Sheet As Object
Dim StyleFamilies As Object 
Dim PageStyles As Object
Dim DefPage As Object
 
Doc = ThisComponent
StyleFamilies = Doc.StyleFamilies
PageStyles = StyleFamilies.getByName("PageStyles")
DefPage = PageStyles.getByName("Default")
 
DefPage.LeftMargin = 1000
DefPage.RightMargin = 1000

Headers and Footers

The headers and footers of a document form part of the page properties and are defined using the com.sun.star.style.PageProperties service. The properties for formatting headers are:

HeaderIsOn (Boolean)
header is activated
HeaderLeftMargin (long)
distance between header and left-hand page margin in hundredths of a millimeter
HeaderRightMargin (long)
distance between header and right-hand page margin in hundredths of a millimeter
HeaderBodyDistance (long)
distance between header and main body of document in hundredths of a millimeter
HeaderHeight (long)
height of header in hundredths of a millimeter
HeaderIsDynamicHeight (Boolean)
height of header is automatically adapted to content
HeaderLeftBorder (struct)
details of the left-hand border of frame around header (com.sun.star.table.BorderLine structure)
HeaderRightBorder (struct)
details of the right-hand border of frame around header (com.sun.star.table.BorderLine structure)
HeaderTopBorder (struct)
details of the top line of the border around header (com.sun.star.table.BorderLine structure)
HeaderBottomBorder (struct)
details of the bottom line of the border around header (com.sun.star.table.BorderLine structure)
HeaderLeftBorderDistance (long)
distance between left-hand border and content of header in hundredths of a millimeter
HeaderRightBorderDistance (long)
distance between right-hand border and content of header in hundredths of a millimeter
HeaderTopBorderDistance (long)
distance between top border and content of header in hundredths of a millimeter
HeaderBottomBorderDistance (long)
distance between bottom border and content of header in hundredths of a millimeter
HeaderIsShared (Boolean)
headers on even and odd pages have the same content (refer to HeaderText , HeaderTextLeft, and HeaderTextRight )
HeaderBackColor (long)
background color of header
HeaderBackGraphicURL (String)
URL of the background graphics that you want to use
HeaderBackGraphicFilter (String)
name of the filter for interpreting the background graphics for the header
HeaderBackGraphicLocation (Enum)
position of the background graphics for the header (value according to com.sun.star.style.GraphicLocation enumeration)
HeaderBackTransparent (Boolean)
shows the background of the header as transparent
HeaderShadowFormat (struct)
details of shadow of header (com.sun.star.table.ShadowFormat structure)

The properties for formatting footers are:

FooterIsOn (Boolean)
footer is activated
FooterLeftMargin (long)
distance between footer and left-hand page margin in hundredths of a millimeter
FooterRightMargin (long)
distance between footer and right-hand page margin in hundredths of a millimeter
FooterBodyDistance (long)
distance between footer and main body of document in hundredths of a millimeter
FooterHeight (long)
height of footer in hundredths of a millimeter
FooterIsDynamicHeight (Boolean)
height of footer is adapted automatically to the content
FooterLeftBorder (struct)
details of left-hand line of border around footer (com.sun.star.table.BorderLine structure)
FooterRightBorder (struct)
details of right-hand line of border around footer (com.sun.star.table.BorderLine structure)
FooterTopBorder (struct)
details of top line of border around footer (com.sun.star.table.BorderLine structure)
FooterBottomBorder (struct)
details of bottom line of border around footer (com.sun.star.table.BorderLine structure)
FooterLeftBorderDistance (long)
distance between left-hand border and content of footer in hundredths of a millimeter
FooterRightBorderDistance (long)
distance between right-hand border and content of footer in hundredths of a millimeter
FooterTopBorderDistance (long)
distance between top border and content of footer in hundredths of a millimeter
FooterBottomBorderDistance (long)
distance between bottom border and content of footer in hundredths of a millimeter
FooterIsShared (Boolean)
the footers on the even and odd pages have the same content (refer to FooterText, FooterTextLeft, and FooterTextRight )
FooterBackColor (long)
background color of footer
FooterBackGraphicURL (String)
URL of the background graphics that you want to use
FooterBackGraphicFilter (String)
name of the filter for interpreting the background graphics for the footer
FooterBackGraphicLocation (Enum)
position of background graphics for the footer (value according to com.sun.star.style.GraphicLocation enumeration)
FooterBackTransparent (Boolean)
shows the background of the footer as transparent
FooterShadowFormat (struct)
details of shadow of footer (com.sun.star.table.ShadowFormat structure)

Changing the Text of Headers and Footers

The content of headers and footers in a spreadsheet is accessed through the following properties:

LeftPageHeaderContent (Object)
content of headers for even pages (com.sun.star.sheet.HeaderFooterContent service)
RightPageHeaderContent (Object)
content of headers for odd pages (com.sun.star.sheet.HeaderFooterContent service)
LeftPageFooterContent (Object)
content of footers for even pages (com.sun.star.sheet.HeaderFooterContent service)
RightPageFooterContent (Object)
content of footers for odd pages (com.sun.star.sheet.HeaderFooterContent service)

If you do not need to distinguish between headers or footers for odd and even pages (the FooterIsShared property is False), then set the properties for headers and footers on odd pages.

All the named objects return an object that supports the com.sun.star.sheet.HeaderFooterContent service. By means of the (non-genuine) properties LeftText, CenterText, and RightText, this service provides three text elements for the headers and footers of Apache OpenOffice Calc.

The following example writes the "Just a Test." value in the left-hand text field of the header from the "Default" template.

Dim Doc As Object
Dim Sheet As Object
Dim StyleFamilies As Object 
Dim PageStyles As Object
Dim DefPage As Object
Dim HText As Object
Dim HContent As Object
Doc = ThisComponent
StyleFamilies = Doc.StyleFamilies
PageStyles = StyleFamilies.getByName("PageStyles")
DefPage = PageStyles.getByName("Default")
 
DefPage.HeaderIsOn = True
HContent = DefPage.RightPageHeaderContent
HText = HContent.LeftText
HText.String = "Just a Test."
DefPage.RightPageHeaderContent = HContent

Note the last line in the example: Once the text is changed, the TextContent object must be assigned to the header again so that the change is effective.

Another mechanism for changing the text of headers and footers is available for text documents (Apache OpenOffice Writer) because these consist of a single block of text. The following properties are defined in the com.sun.star.style.PageProperties service:

HeaderText (Object)
text object with content of the header (com.sun.star.text.XText service)
HeaderTextLeft (Object)
text object with content of headers on left-hand pages (com.sun.star.text.XText service)
HeaderTextRight (Object)
text object with content of headers on right-hand pages (com.sun.star.text.XText service)
FooterText (Object)
text object with content of the footer (com.sun.star.text.XText service)
FooterTextLeft (Object)
text object with content of footers on left-hand pages (com.sun.star.text.XText service)
FooterTextRight (Object)
text object with content of footers on right-hand pages (com.sun.star.text.XText service)

The following example creates a header in the "Default" page style for text documents and adds the text "Just a Test" to the header.

Dim Doc As Object
Dim Sheet As Object
Dim StyleFamilies As Object 
Dim PageStyles As Object
Dim DefPage As Object
Dim HText As Object
 
Doc = ThisComponent
StyleFamilies = Doc.StyleFamilies
PageStyles = StyleFamilies.getByName("PageStyles")
DefPage = PageStyles.getByName("Default")
 
DefPage.HeaderIsOn = True
HText = DefPage.HeaderText 
 
HText.String = "Just a Test."

In this instance, access is provided directly through the HeaderText property of the page style rather than the HeaderFooterContent object.

Centering (Spreadsheets Only)

The com.sun.star.sheet.TablePageStyle service is only used in Apache OpenOffice Calc page styles and allows cell ranges that you want printed to be centered on the page. This service provides the following properties:

CenterHorizontally (Boolean)
table content is centered horizontally
CenterVertically (Boolean)
table content is centered vertically

Definition of Elements to be Printed (Spreadsheets Only)

When you format sheets, you can define whether page elements are visible. For this purpose, the com.sun.star.sheet.TablePageStyle service provides the following properties:

PrintAnnotations (Boolean)
prints cell comments
PrintGrid (Boolean)
prints the cell gridlines
PrintHeaders (Boolean)
prints the row and column headings
PrintCharts (Boolean)
prints charts contained in a sheet
PrintObjects (Boolean)
prints embedded objects
PrintDrawing (Boolean)
prints draw objects
PrintDownFirst (Boolean)
if the contents of a sheet extend across several pages, they are first printed in vertically descending order, and then down the right-hand side.
PrintFormulas (Boolean)
prints the formulas instead of the calculated values
PrintZeroValues (Boolean)
prints the zero values


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