setWrapText-methods: Specifying text wrapping behaviour

Description Usage Arguments Author(s) See Also Examples

Description

Specifies if text should be wrapped in a cell.

Usage

1
2
## S4 method for signature 'cellstyle'
setWrapText(object,wrap)

Arguments

object

The cellstyle to manipulate

wrap

If wrap = TRUE, the text is wrapped if it exceeds the width of the cell - otherwise not.

Author(s)

Martin Studer
Mirai Solutions GmbH https://mirai-solutions.ch

See Also

workbook, cellstyle, setCellStyle, setStyleAction

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Not run: 
# Load workbook (create if not existing)
wb <- loadWorkbook("setWrapText.xlsx", create = TRUE)

# Create a worksheet
createSheet(wb, name = "cellstyles")

# Create a dummy data set with some long text
text <- data.frame(
     Text = "Some very very very very very very very long text")

# Write the value to the 'cellstyles' worksheet in the 
# top left corner (cell A1)
writeWorksheet(wb, text, sheet = "cellstyles", startRow = 1, 
               startCol = 1, header = FALSE)

# Create a custom anonymous cell style
cs <- createCellStyle(wb)

# Specify to wrap the text
setWrapText(cs, wrap = TRUE)

# Set the cell style created above for the top left cell (A1) 
# in the 'cellstyles' worksheet
setCellStyle(wb, sheet = "cellstyles", row = 1, col = 1, 
             cellstyle = cs)

# Save the workbook
saveWorkbook(wb)

# clean up 
file.remove("setWrapText.xlsx")

## End(Not run)

XLConnect documentation built on Oct. 1, 2021, 5:06 p.m.