set_xlsx_rowheights: Set row heights in Xlsx files

set_xlsx_rowheightsR Documentation

Set row heights in Xlsx files

Description

This function is a light wrapper to perform these steps from the very useful openxlsx R package:

Usage

set_xlsx_rowheights(
  xlsxFile,
  sheet = 1,
  rows = seq_along(heights) + 1,
  heights = 17,
  ...
)

Arguments

xlsxFile

character filename to a file with ".xlsx" extension, or Workbook object defined in the openxlsx package. When xlsxFile is a Workbook the output is not saved to a file.

sheet

value passed to openxlsx::setRowHeights() indicating the worksheet to affect. It can either be an integer value, or the character name of a sheet.

rows

⁠integer vector⁠ indicating the row numbers to affect.

heights

⁠numeric vector⁠ indicating the height of each column defined by rows.

...

additional arguments are passed to openxlsx::setRowHeights().

Details

  • openxlsx::loadWorkbook()

  • openxlsx::setRowHeights()

  • openxlsx::saveWorkbook()

Note that when only the argument heights is defined, the argument rows will point to row 2 and lower, thus skipping the first (header) row. Define rows specifically in order to affect the header row as well.

Value

Workbook object as defined by the openxlsx package is returned invisibly with invisible(). This Workbook can be used in argument wb to provide a speed boost when saving multiple sheets to the same file.

See Also

Other jam export functions: applyXlsxCategoricalFormat(), applyXlsxConditionalFormat(), readOpenxlsx(), set_xlsx_colwidths(), writeOpenxlsx()

Examples

## Not run: 
   df <- data.frame(a=LETTERS[1:5], b=1:5);
   jamba::writeOpenxlsx(x=df,
      file="jamba_test.xlsx",
      sheetName="test_jamba");

   ## by default, rows will start at row 2, skipping the header
   jamba::set_xlsx_rowheights(file="jamba_test.xlsx",
      sheetName="test_jamba",
      heights=rep(17, nrow(df))
   )

   ## to include the header row
   jamba::set_xlsx_rowheights(file="jamba_test.xlsx",
      sheetName="test_jamba",
      rows=seq_len(nrow(df)+1),
      heights=rep(17, nrow(df)+1)
   )

## End(Not run)


jmw86069/jamba documentation built on March 26, 2024, 5:26 a.m.