I'm dumping into a file a report, and I'm using openxlsx to do so, as it can be seen below:
library(openxlsx)
set.seed(100)
dataset <- data.frame(A=runif(100),B=runif(100),C=sample(c("A","B","C"), 100, replace=T))
hs <- createStyle(fontColour = "#ffffff", fgFill = "#4F80BD",
halign = "center", valign = "center", textDecoration = "bold",
border = "TopBottomLeftRight")
wb = createWorkbook()
addWorksheet(wb = wb, sheetName = "example", gridLines = T, zoom = 70)
writeData(
wb,
sheet = "example",
x = dataset,
withFilter=T,
borders="all",
borderStyle="thin",
headerStyle=hs
)
# The width of the columns will be automatically adjusted
setColWidths(wb, sheet = "example", cols=1:ncol(dataset), widths = "auto")
saveWorkbook(wb, "example.xlsx", overwrite=T)
I've activated the withFilter option, so that the end user will be able to select only subsets of data. However, I'd like to activate one filter so that by default only a subset is shown; e.g. I'd like to show only records where the column C equals to "B".
I've reviewed the documentation of the openxlsx package, but I can't find how to do it anywhere.