Package 'forgts'

Title: Convert Formatted Spreadsheets to Presentation-Ready Display Tables
Description: Reads cell contents plus formatting from a spreadsheet file and creates an editable 'gt' object with the same data and formatting. Supports the most commonly-used cell and text styles including colors, fills, font weights and decorations, and borders.
Authors: Luis D. Verde Arregoitia [aut, cre, cph]
Maintainer: Luis D. Verde Arregoitia <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1.9000
Built: 2025-02-04 19:19:44 UTC
Source: https://github.com/luisdva/forgts

Help Index


Apply Spreadsheet Formatting to gt Table

Description

Applies formatting to a gt table based on information extracted from the spreadsheet file.

Usage

apply_styling(gt_object, formatRdy)

Arguments

gt_object

A gt object.

formatRdy

A data frame with formatting definitions.

Value

A great table!

Examples

example_spreadsheet <- system.file("extdata/rodentsheet.xlsx", package = "forgts")
sprdsht_data <- readxl::read_excel(example_spreadsheet)
gt_table <- gt::gt(sprdsht_data)
format_long <- get_formatting(example_spreadsheet)
format_ready <- translate_defs(format_long)
apply_styling(gt_table, format_ready)

Creat gt from spreadsheet

Description

Wrapper. Reads a spreadsheet file including most formatting information and creates a formatted gt table with the same data and formatting.

Usage

forgts(file, sheet = NULL)

Arguments

file

Path to a spreadsheet.

sheet

A character string with the name of a sheet within a workbook, or an integer with the position of the sheet. Defaults to the first sheet if left unspecified.

Value

A great table!

Examples

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

Get Spreadsheet Formatting

Description

Extracts formatting information from a spreadsheet.

Usage

get_formatting(xlfilepath, sheet = NULL)

Arguments

xlfilepath

A character string specifying the path to the spreadsheet.

sheet

A character string with the name of a sheet within a workbook, or an integer with the position of the sheet. Defaults to the first sheet if left unspecified.

Value

A data frame or list with parsed formatting information.

Examples

example_file <- system.file("extdata/rodentsheet.xlsx", package = "forgts")
get_formatting(example_file)

rodentsheet.xlsx spreadsheet

Description

Open XML Format Spreadsheet with 1 sheet, 5 columns, and 8 rows. Toy dataset with data on measurements for rodent specimens, extracted from Verde Arregoitia et al. (2017; doi:10.5281/zenodo.201147). Cells and cell content have formatting added at random for demonstration purposes.


Colwise formatting

Description

Colwise formatting

Usage

target_var_fmt(format_joined, spsheet, col_name)

Arguments

format_joined

A data frame produced internally by get_formatting

spsheet

Data frame version of spraedsheet.

col_name

Variable to operate on.

Value

Modified data frame in long format.


Translate Formatting Definitions

Description

Convert formatting information into arguments that can be used by gt.

Usage

translate_defs(format_long)

Arguments

format_long

Data frame produced by get_formatting containing raw formatting information.

Value

A data frame with formatting information compatible with gt.

Examples

example_spreadsheet <- system.file("extdata/rodentsheet.xlsx", package = "forgts")
format_long <- get_formatting(example_spreadsheet)
translate_defs(format_long)