auto_heights: Compute optimal row heights

View source: R/helperFunctions.R

auto_heightsR Documentation

Compute optimal row heights

Description

Compute optimal row heights for cell with fixed with and enabled automatic row heights parameter

Usage

auto_heights(
  wb,
  sheet,
  selected,
  fontsize = NULL,
  factor = 1,
  base_height = 15,
  extra_height = 12
)

Arguments

wb

workbook

sheet

worksheet

selected

selected rows

fontsize

font size, optional (get base font size by default)

factor

factor to manually adjust font width, e.g., for bold fonts, optional

base_height

basic row height, optional

extra_height

additional row height per new line of text, optional

Value

list of indices of columns with fixed widths and optimal row heights

Author(s)

David Breuer

Examples

## Create new workbook
wb <- createWorkbook()
addWorksheet(wb, "Sheet")
sheet <- 1

## Write dummy data
long_string <- "ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC"
writeData(wb, sheet, c("A", long_string, "CCC"), startCol = 2, startRow = 3)
writeData(wb, sheet, c(4, 5), startCol = 4, startRow = 3)

## Set column widths and get optimal row heights
setColWidths(wb, sheet, c(1,2,3,4), c(10,20,10,20))
auto_heights(wb, sheet, 1:5)


openxlsx documentation built on Sept. 20, 2024, 5:08 p.m.