IntegralEnvision / integral

Package for Integral functions
https://integralenvision.github.io/integral/
Other
0 stars 0 forks source link

Integral Style Excel Formatting #70

Open jzadra opened 1 year ago

jzadra commented 1 year ago

Lets use this issue to keep track of the excel formatting functionality goals and progress.

Features:

Things to look into:

General Thoughts/Questions:

jzadra commented 1 year ago

Pre-defined styles:

Lets brainstorm styles here, and consider a standard naming scheme.

Should we prefix all with something like style_? Should we have a single style function for border that has arguments for top/bottom/double, etc, or keep them standalone?

Lets also make sure that all styles are stacked by default.

border_top <- createStyle(border = "top")
border_bottom <- createStyle(border = "bottom")
border_bottom_double <- createStyle(border = "bottom", borderStyle = "double")
halign_left <- createStyle(halign = "left")
halign_center <- createStyle(halign = "center")
halign_right <- createStyle(halign = "right")
italic <- createStyle(textDecoration = "italic")
wrap_text <- createStyle(wrapText = TRUE)
indent <- createStyle(indent = 1)
bold <- createStyle(textDecoration = "bold")
valign_top <- createStyle(valign = "top")
valign_bottom <- createStyle(valign = "bottom")
jzadra commented 1 year ago

Detecting cells to merge, here is something in progress that detects contiguous runs of the same value:


index_identical_rows <- function(.data, column, startRow = 1) {
  column <- rlang::enquo(column)

  .data %>%
    dplyr::mutate(start = (!!column != dplyr::lag(!!column) | is.na(dplyr::lag(!!column))) & !is.na(!!column),
           end = (!!column != dplyr::lead(!!column) | is.na(dplyr::lead(!!column))) & !is.na(!!column)) %>%
    dplyr::summarize(start = which(start),
              end = which(end)) %>%
    dplyr::filter(start != end) %>%
    dplyr::mutate(dplyr::across(tidyselect::everything(), ~ . + startRow - 1)) %>%
    purrr::array_tree(margin = 1)
}