Getting started

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

forgts leverages readxl, tidyxl, and unheadr to read a spreadsheet and its formatting information and produce a gt object with the same cell and text formatting as the input file.

The main function in this package is forgts::forgts(), which simply takes path to an xlsx file and an optional sheet number.

The text and cell formats currently supported include:

Please note that formatting in the headers is ignored intentionally in this package, and that the cell and text formatting is added iteratively on top of gt defaults. The gt object produced can be styled further or exported.

forgts ships with an example spreadsheet file (rodentsheet.xlsx) that looks like this:

knitr::include_graphics("img/spsheetog.png")

The function forgts() will read the file and produce a gt object.

library(forgts)
###
example_spreadsheet <- system.file("extdata/rodentsheet.xlsx", package = "forgts")

forgts(example_spreadsheet)
# note that the resulting gt is responsive to dark and light modes on a browser

forgts() may be used in RMarkdown and Quarto documents, and the resulting gt tables may be exported with gt::gtsave().



Try the forgts package in your browser

Any scripts or data that you put into this service are public.

forgts documentation built on April 12, 2025, 1:46 a.m.