Learn R Programming

DescTools (version 0.99.56)

WrdTableHeading: Insert Headings for a Table in Word

Description

Inserting headings in a table can be hard, when column headings should span several columns. This function helps to easily insert headings and merge cells.

Usage

WrdTableHeading(wtab, text, bold = TRUE, 
                alignment = wdConst$wdAlignParagraphCenter, 
                merge_cols = NULL, wrd = DescToolsOptions("lastWord"))

Value

Nothing returned.

Arguments

wtab

the handle to a table in a word document

text

the text for the headings

bold

logical, for setting bold column headings, will be recycled. Default is TRUE.

alignment

the alignment in the column headings, must be one out of the Word constant list wdConst$wdAlignParagraph.

merge_cols

a vector consisting of entries to merge cells in the form "<first cell>:<last cell>", example merge_cols=c("2:4", "7:8") would merge the column headings 2:4 to one cell and 7:8 as well.

wrd

the pointer to a word instance. Can be a new one, created by GetNewWrd() or an existing one, created by GetCurrWrd(). Default is the last created pointer stored in DescToolsOptions("lastWord").

Author

Andri Signorell <andri@signorell.net

See Also

WrdTable

Examples

Run this code
if (FALSE)  # Windows-specific example
wrd <- GetNewWrd()
wtab <- WrdTable(nrow=3, ncol=5, wrd=wrd)

# insert headings and merge 1:2 and 4:5, such as there are 
# only 3 headings
WrdTableHeading(wtab, text=c("First","Second", 
                              "Third"),
                  alignment=c(wdConst$wdAlignParagraphLeft, 
                              rep(wdConst$wdAlignParagraphCenter, 2)), 
                  merge_cols = c("1:2", "4:5"))


Run the code above in your browser using DataLab