Skip to content

Format Pivot Tables #776

Answered by JanMarvin
carolinavelarde asked this question in Q&A
Aug 30, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Hi @carolinavelarde ,

it's possible but the function is not well polished. I had do to dig a bit into the code to create an example, have a look here:

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()

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JanMarvin
Comment options

@carolinavelarde
Comment options

@JanMarvin
Comment options

Answer selected by carolinavelarde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants