ycphs / openxlsx

openxlsx - a fast way to read and write complex xslx files
https://ycphs.github.io/openxlsx/
Other
220 stars 73 forks source link

Set filter choices for written data table #443

Open jwhendy opened 10 months ago

jwhendy commented 10 months ago

Is your feature request related to a problem? Please describe. Using writeDataTable is great, however when sharing my work with colleagues, the expectation would be to have certain filters set. I cannot find a way to not only have filters, but also to set how I want them filtered when creating the workbook. Thus, I need to write it, open it, set the filters myself, then save again.

Describe the solution you'd like I could envision this as part of writeDataTable, or a separate helper function similar to setColWidths (e.g. setDataTableOptions?).

So maybe something like this, assuming I write a table with colName1, with values value1, value2, value3, and NA (blank). This would generate the table such that the equivalent user action would be to click the column drop down, uncheck value3 and leave Blank selected.

writeDataTable(wb, sheet, x, ..., filters = list(colName1 = c(value1, value2, NA)), ...)

Describe alternatives you've considered I've google around and found what I think is this question on SO, but the only answer is to use VBS, which I'm not interested in doing.

Additional context Add any other context or screenshots about the feature request here.