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 |
Applies formatting to a gt table based on information extracted from the spreadsheet file.
apply_styling(gt_object, formatRdy)
apply_styling(gt_object, formatRdy)
gt_object |
A gt object. |
formatRdy |
A data frame with formatting definitions. |
A great table!
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)
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)
Wrapper. Reads a spreadsheet file including most formatting information and creates a formatted gt table with the same data and formatting.
forgts(file, sheet = NULL)
forgts(file, sheet = NULL)
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. |
A great table!
example_spreadsheet <- system.file("extdata/rodentsheet.xlsx", package = "forgts") forgts(example_spreadsheet)
example_spreadsheet <- system.file("extdata/rodentsheet.xlsx", package = "forgts") forgts(example_spreadsheet)
Extracts formatting information from a spreadsheet.
get_formatting(xlfilepath, sheet = NULL)
get_formatting(xlfilepath, sheet = NULL)
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. |
A data frame or list with parsed formatting information.
example_file <- system.file("extdata/rodentsheet.xlsx", package = "forgts") get_formatting(example_file)
example_file <- system.file("extdata/rodentsheet.xlsx", package = "forgts") get_formatting(example_file)
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
target_var_fmt(format_joined, spsheet, col_name)
target_var_fmt(format_joined, spsheet, col_name)
format_joined |
A data frame produced internally by |
spsheet |
Data frame version of spraedsheet. |
col_name |
Variable to operate on. |
Modified data frame in long format.
Convert formatting information into arguments that can be used by gt
.
translate_defs(format_long)
translate_defs(format_long)
format_long |
Data frame produced by |
A data frame with formatting information compatible with gt.
example_spreadsheet <- system.file("extdata/rodentsheet.xlsx", package = "forgts") format_long <- get_formatting(example_spreadsheet) translate_defs(format_long)
example_spreadsheet <- system.file("extdata/rodentsheet.xlsx", package = "forgts") format_long <- get_formatting(example_spreadsheet) translate_defs(format_long)