R-package / styledTables

Convert your R data.frame into a fully styled table that can be exported to LaTeX and Excel
https://r-package.github.io/styledtable
GNU General Public License v3.0
3 stars 2 forks source link

write another excel export function #22

Open GregorDeCillia opened 5 years ago

GregorDeCillia commented 5 years ago

It would be nice to get a new excel export function that can directly create xlsx files such as

st <- styledTable(JohnsonJohnson)
new_write_excel(st, "file.xlsx")

The current function write_excel writes into a sheet object by reference, which is more flexible, but also harder to use.

Namespace implications

We should consider renaming write_excel. My suggestion:

write_excel(st, "file.xlsx")         # <- new function
write_excel_sheet(st, sheet_obj)     # <- formerly write_excel

If we don't want to introduce breaking changes, we could also use

write_xlsx(st, "file.xlsx")          # <- new function
write_excel(st, sheet_obj)           # <- leave unchanged

The reason why I prefer the first option is, that this way write_excel is consistent with write_pdf, write_png and so on in the sense that a file is produced.

GregorDeCillia commented 5 years ago

The body of the new function can be as simple as these lines from the getting started vignette

https://github.com/R-package/styledTables/blob/5d38b6b6ef7bcdabc30e98e3a60a66c3c145aa51/vignettes/styledTables.Rmd#L120-L130

altough I would suggest to support most or all parameters from xlsx::write.xlsx to get consistency with this wiedly known function.

GregorDeCillia commented 5 years ago

Updates after talking to @a-maldet