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

[pivot tables] add show_data_as and compact/outline #833

Merged
merged 3 commits into from Oct 27, 2023
Merged

Conversation

JanMarvin
Copy link
Owner

library(openxlsx2)

wb <- wb_workbook() %>% wb_add_worksheet() %>% wb_add_data(x = mtcars)

df <- wb_data(wb, sheet = 1)

wb <- wb %>%
  wb_add_pivot_table(
    df,
    dims = "A3",
    filter = "am",
    rows = "cyl",
    cols = "gear",
    data = "disp",
    params = list(
      show_data_as = c("percentOfRow"),
      numfmts = c(formatCode = "#.##%")
    )
  )

if (interactive()) wb$open()

@JanMarvin
Copy link
Owner Author

library(openxlsx2)

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,
  rows = "cyl", cols = "gear",
  data = c("disp", "hp"),
  fun = c("sum", "count"),
  params = list(
    numfmt = c(formatCode = "$ ###", formatCode = "#"),
    # tabular form
    compact = FALSE, outline = FALSE, compactData = "0",
    # disable totals
    rowGrandTotals = "0", colGrandTotals = "0"
  ))

if (interactive()) wb$open()

@JanMarvin JanMarvin changed the title [pivot tables] optional param show_data_as [pivot tables] add show_data_as and compact/outline Oct 27, 2023
@JanMarvin JanMarvin merged commit 91ea2b7 into main Oct 27, 2023
8 of 9 checks passed
@JanMarvin JanMarvin deleted the show_data_as branch October 27, 2023 21:24
@JanMarvin JanMarvin mentioned this pull request Nov 23, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant