Title: | Convert Formatted Spreadsheets to Presentation-Ready Display Tables |
Version: | 0.0.1 |
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. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2.9000 |
Imports: | dplyr, gt, purrr, readxl, rlang, tibble, tidyr, tidyxl |
Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
URL: | https://github.com/luisDVA/forgts, https://luisdva.github.io/forgts/ |
BugReports: | https://github.com/luisDVA/forgts/issues |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2025-01-30 17:54:16 UTC; luisd |
Author: | Luis D. Verde Arregoitia
|
Maintainer: | Luis D. Verde Arregoitia <luis@liomys.mx> |
Repository: | CRAN |
Date/Publication: | 2025-01-31 11:40:04 UTC |
forgts: 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.
Author(s)
Maintainer: Luis D. Verde Arregoitia luis@liomys.mx (ORCID) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/luisDVA/forgts/issues
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 |
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 |
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)