Learn R Programming

huxtable (version 4.0.1)

as_Workbook: Convert a huxtable for Excel

Description

If the openxlsx package is installed, Huxtables can be converted to openxlsx::openxlsx() Worbook objects, for use in Excel documents.

Usage

as_Workbook(ht, ...)

# S3 method for huxtable as_Workbook(ht, Workbook = NULL, sheet = "Sheet 1", write_caption = TRUE, ...)

Arguments

ht

A huxtable.

...

Not used.

Workbook

An existing Workbook object. By default, a new workbook will be created.

sheet

Name for the worksheet where the huxtable will be created.

write_caption

If TRUE, print any caption in the row above or below the table.

Value

An object of class Workbook.

Details

Use openxlsx::saveWorkbook() to save the resulting object to an Excel file.

Properties are supported with the following exceptions:

  • Non-numeric column widths and row heights, table width and height.

  • Decimal padding.

  • Cell padding.

  • Table position.

Huxtable tries to guess appropriate widths and height for rows and columns; numeric width() and height() are treated as scaling factors.

Contents are only stored as numbers if a whole column is numeric as defined by is_a_number(); otherwise they are stored as text.

Examples

Run this code
# NOT RUN {
ht <- hux(a = 1:3, b = 1:3)
wb <- as_Workbook(ht)
# }
# NOT RUN {
openxlsx::saveWorkbook(wb, "my-excel-file.xlsx")
# }

Run the code above in your browser using DataLab