Format Pivot Tables #776
Answered
by
JanMarvin
carolinavelarde
asked this question in
Q&A
-
Hi! I have been using openxlsx and openxlsx2 for the past few weeks. I'm creating pivot tables with openxlsx2 and want to know if there is a way to format currency for pivot table values. I''ve tried manually adding style to the specific cells with currency but it does not work. |
Beta Was this translation helpful? Give feedback.
Answered by
JanMarvin
Aug 30, 2023
Replies: 1 comment 3 replies
-
Hi @carolinavelarde , it's possible but the function is not well polished. I had library(openxlsx2)
## Pivot table example 1
wb <- wb_workbook() %>% wb_add_worksheet() %>% wb_add_data(x = mtcars, inline_strings = F)
wb$add_numfmt(dims = wb_dims(x = mtcars, cols = "disp"), numfmt = "$ #,###")
df <- wb_data(wb)
# basic pivot table with filter, rows, cols and data
wb$add_pivot_table(df, dims = "A3", filter = "mpg", rows = "cyl", cols = "gear", data = "disp",
params = list(
numfmt = c(formatCode = "$ ###")
))
if (interactive()) wb$open() |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
carolinavelarde
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @carolinavelarde ,
it's possible but the function is not well polished. I had
doto dig a bit into the code to create an example, have a look here: