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

write another excel export function #22

Open
GregorDeCillia opened this issue May 24, 2019 · 2 comments
Open

write another excel export function #22

GregorDeCillia opened this issue May 24, 2019 · 2 comments
Assignees
Labels
API Syntax for styling my table breaking export
Milestone

Comments

@GregorDeCillia
Copy link
Member

GregorDeCillia commented May 24, 2019

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 GregorDeCillia added API Syntax for styling my table export labels May 24, 2019
@GregorDeCillia GregorDeCillia added this to the CRAN release milestone May 24, 2019
@GregorDeCillia
Copy link
Member Author

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

library(xlsx)
# open new xlsx workbook and create a worksheet
wb <- createWorkbook()
sheet <- createSheet(wb, "iris_table")
# insert the styled table in the worksheet
write_excel(sheet, st2)
# save the workbook
saveWorkbook(wb, "test.xlsx")

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

@GregorDeCillia
Copy link
Member Author

Updates after talking to @a-maldet

  • we should also consider the parameters in openxlsx::write.xlsx when deciding about the parameter names of the new function
  • the new function will be called write_xlsx for consistency
  • braking changes are OK, if they increase the usability
  • The current version of write_excel will be removed from the namespace altogether since there are too many "under the hood" things happening

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Syntax for styling my table breaking export
Projects
None yet
Development

No branches or pull requests

2 participants