Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change num_fmt to numfmt #939

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/class-style_mgr.R
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ style_mgr <- R6::R6Class("wbStylesMgr", {
border_id <- self$get_border_id(border_xml)
}

cell_style_xml <- create_cell_style(num_fmt_id = numFmtId, font_id = font_id, fill_id = fill_id, border_id = border_id, is_cell_style_xf = TRUE)
cell_style_xml <- create_cell_style(numfmt_id = numFmtId, font_id = font_id, fill_id = fill_id, border_id = border_id, is_cell_style_xf = TRUE)
attr(cell_style_xml, "cellStyleXf") <- TRUE
self$add(cell_style_xml, name)
xf_fr_id <- self$get_cellStyleXf_id(name)
Expand Down
12 changes: 6 additions & 6 deletions R/class-workbook-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3119,7 +3119,7 @@ wb_add_numfmt <- function(
#' @param border_id border ID to apply
#' @param fill_id fill ID to apply
#' @param font_id font ID to apply
#' @param num_fmt_id number format ID to apply
#' @param numfmt_id number format ID to apply
#' @param xf_id xf ID to apply
#' @param ... additional arguments
#' @examples
Expand Down Expand Up @@ -3164,7 +3164,7 @@ wb_add_cell_style <- function(
indent = NULL,
justify_last_line = NULL,
locked = NULL,
num_fmt_id = NULL,
numfmt_id = NULL,
pivot_button = NULL,
quote_prefix = NULL,
reading_order = NULL,
Expand Down Expand Up @@ -3195,7 +3195,7 @@ wb_add_cell_style <- function(
indent = indent,
justify_last_line = justify_last_line,
locked = locked,
num_fmt_id = num_fmt_id,
numfmt_id = numfmt_id,
pivot_button = pivot_button,
quote_prefix = quote_prefix,
reading_order = reading_order,
Expand Down Expand Up @@ -3250,7 +3250,7 @@ wb_add_named_style <- function(
#' @param font_name the font name
#' @param font_size the font size
#' @param font_color the font color (a `wb_color()` object)
#' @param num_fmt the number format
#' @param numfmt the number format
#' @param border logical if borders are applied
#' @param border_color the border color
#' @param border_style the border style
Expand All @@ -3277,7 +3277,7 @@ wb_add_dxfs_style <- function(
font_name = NULL,
font_size = NULL,
font_color = NULL,
num_fmt = NULL,
numfmt = NULL,
border = NULL,
border_color = wb_color(getOption("openxlsx2.borderColor", "black")),
border_style = getOption("openxlsx2.borderStyle", "thin"),
Expand All @@ -3295,7 +3295,7 @@ wb_add_dxfs_style <- function(
font_name = font_name,
font_size = font_size,
font_color = font_color,
num_fmt = num_fmt,
numfmt = numfmt,
border = border,
border_color = border_color,
border_style = border_style,
Expand Down
12 changes: 6 additions & 6 deletions R/class-workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -7190,7 +7190,7 @@ wbWorkbook <- R6::R6Class(
#' @param border_id border ID to apply
#' @param fill_id fill ID to apply
#' @param font_id font ID to apply
#' @param num_fmt_id number format ID to apply
#' @param numfmt_id number format ID to apply
#' @param xf_id xf ID to apply
#' @return The `wbWorkbook` object, invisibly
add_cell_style = function(
Expand All @@ -7211,7 +7211,7 @@ wbWorkbook <- R6::R6Class(
indent = NULL,
justify_last_line = NULL,
locked = NULL,
num_fmt_id = NULL,
numfmt_id = NULL,
pivot_button = NULL,
quote_prefix = NULL,
reading_order = NULL,
Expand Down Expand Up @@ -7256,7 +7256,7 @@ wbWorkbook <- R6::R6Class(
indent = indent,
justifyLastLine = justify_last_line,
locked = locked,
numFmtId = num_fmt_id,
numFmtId = numfmt_id,
pivotButton = pivot_button,
quotePrefix = quote_prefix,
readingOrder = reading_order,
Expand Down Expand Up @@ -7414,7 +7414,7 @@ wbWorkbook <- R6::R6Class(
#' @param font_name the font name
#' @param font_size the font size
#' @param font_color the font color (a `wb_color()` object)
#' @param num_fmt the number format
#' @param numfmt the number format
#' @param border logical if borders are applied
#' @param border_color the border color
#' @param border_style the border style
Expand All @@ -7431,7 +7431,7 @@ wbWorkbook <- R6::R6Class(
font_name = NULL,
font_size = NULL,
font_color = NULL,
num_fmt = NULL,
numfmt = NULL,
border = NULL,
border_color = wb_color(getOption("openxlsx2.borderColor", "black")),
border_style = getOption("openxlsx2.borderStyle", "thin"),
Expand All @@ -7449,7 +7449,7 @@ wbWorkbook <- R6::R6Class(
font_name = font_name,
font_size = font_size,
font_color = font_color,
num_fmt = num_fmt,
numfmt = numfmt,
border = border,
border_color = border_color,
border_style = border_style,
Expand Down
26 changes: 13 additions & 13 deletions R/wb_styles.R
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
#' @param border_id dummy
#' @param fill_id dummy
#' @param font_id dummy
#' @param num_fmt_id a numFmt ID for a builtin style
#' @param numfmt_id a numFmt ID for a builtin style
#' @param pivot_button dummy
#' @param quote_prefix dummy
#' @param xf_id dummy
Expand Down Expand Up @@ -434,7 +434,7 @@
border_id = "",
fill_id = "",
font_id = "",
num_fmt_id = "",
numfmt_id = "",
pivot_button = "",
quote_prefix = "",
xf_id = "",
Expand All @@ -452,11 +452,11 @@
locked = "",
...
) {
n <- length(num_fmt_id)

arguments <- c(ls(), "is_cell_style_xf")
standardize_case_names(..., arguments = arguments)
args <- list(...)
n <- length(numfmt_id)

is_cell_style_xf <- isTRUE(args$is_cell_style_xf)

Expand All @@ -477,7 +477,7 @@
if (is_cell_style_xf && isTRUE(font_id > "1")) applyFont <- "0"

applyNumberFormat <- ""
if (any(num_fmt_id != "")) applyNumberFormat <- "1"
if (any(numfmt_id != "")) applyNumberFormat <- "1"
if (is_cell_style_xf) applyNumberFormat <- "0"

applyProtection <- ""
Expand All @@ -495,7 +495,7 @@
borderId = rep(as_xml_attr(border_id), n),
fillId = rep(as_xml_attr(fill_id), n),
fontId = rep(as_xml_attr(font_id), n),
numFmtId = as_xml_attr(num_fmt_id),
numFmtId = as_xml_attr(numfmt_id),
pivotButton = rep(as_xml_attr(pivot_button), n),
quotePrefix = rep(as_xml_attr(quote_prefix), n),
xfId = rep(as_xml_attr(xf_id), n),
Expand Down Expand Up @@ -675,7 +675,7 @@
#' (Defaults to black)
#' @param font_size Font size. A numeric greater than 0.
#' By default, the workbook base font size is used. (Defaults to 11)
#' @param num_fmt Cell formatting. Some custom openxml format
#' @param numfmt Cell formatting. Some custom openxml format
#' @param border `NULL` or `TRUE`
#' @param border_color "black"
#' @param border_style "thin"
Expand Down Expand Up @@ -713,7 +713,7 @@
font_name = NULL,
font_size = NULL,
font_color = NULL,
num_fmt = NULL,
numfmt = NULL,
border = NULL,
border_color = wb_color(getOption("openxlsx2.borderColor", "black")),
border_style = getOption("openxlsx2.borderStyle", "thin"),
Expand All @@ -733,15 +733,15 @@
)
standardize(..., arguments = arguments)

if (is.null(font_color)) font_color <- ""
if (is.null(font_size)) font_size <- ""
if (is.null(text_bold)) text_bold <- ""
if (is.null(text_strike)) text_strike <- ""
if (is.null(text_italic)) text_italic <- ""
if (is.null(font_color)) font_color <- ""
if (is.null(font_size)) font_size <- ""
if (is.null(text_bold)) text_bold <- ""
if (is.null(text_strike)) text_strike <- ""
if (is.null(text_italic)) text_italic <- ""
if (is.null(text_underline)) text_underline <- ""

# found numFmtId=3 in MS365 xml not sure if this should be increased
if (!is.null(num_fmt)) num_fmt <- create_numfmt(3, num_fmt)
if (!is.null(numfmt)) numfmt <- create_numfmt(3, numfmt)

font <- create_font(
color = font_color, name = font_name,
Expand Down Expand Up @@ -796,7 +796,7 @@
"dxf",
xml_children = c(
font,
num_fmt,

Check warning on line 799 in R/wb_styles.R

View workflow job for this annotation

GitHub Actions / lint

file=R/wb_styles.R,line=799,col=7,[object_usage_linter] no visible binding for global variable 'num_fmt'
fill,
border
)
Expand Down
4 changes: 2 additions & 2 deletions man/create_cell_style.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/create_dxfs_style.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/wbWorkbook.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/wb_add_cell_style.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/wb_add_dxfs_style.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.