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
Feature request: add an "update" argument to write.xlsx #190
Comments
|
Isn't read.xlsx(...) intented for this? |
|
There are two issues I encounter when trying to use the approach you outlined: First, if a spreadsheet has multiple sheets, you can only read in one sheet at a time (which makes sense for read.xlsx given that the output is a dataframe) Second, write.xlsx can't just replace a single sheet, it seems to obliterate the entire workbook and make a new workbook with just one worksheet. My feature request is to have an easy way to leave everything about an existing workbook intact, except write a dataframe to one of the sheets (either a new one, or overwrite the data on an existing sheet). |
|
@vergilcw I think you are looking for: This routine adds new sheet(s), and does not touch anything else in the workbook. |
|
What if I have a sheet within an existing workbook, that, let's say has already been formatted in a specific way: column widths are pre-set (knowing what data will be going in there helps), maybe a specific font and font size are in the sheet already. It would be nice to just write a dataframe to that sheet, and not touch anything else about the sheet. This would be roughtly the equivalent of opening the workbook, copying data from somewhere else, and "paste values" (preserving formatting). Neither of the solutions offered thus far get us there. |
|
I believe the solution suggested by nicholaelaw does exactly what you want. |
|
Yes, I see you're correct. Thanks for providing an example proof! I guess from here It's up to me to create a little wrapper function for syntactical sugar that avoids the step of loading and saving the workbook, with syntax that looks something like: Shouldn't be too difficult on my end. |
|
I find that the |
Currently write.xlsx is a great shorthand way to create a workbook. I am h oping it would also be fairly straightforward to allow you to update a workbook that already exists.
I'm envisioning a new argument to write.xlsx called
updatewhich takes either TRUE or FALSE as arguments. For update=TRUE, the function should first attempt to read the file and if it finds a valid excel workbook, only make updates to the sheets with data listed in the x argument. You could even leave the formatting alone and update just the data values for those sheets, which would preserve any formatting that existed previously.This would significantly speed up workflows for folks doing work in R, who are collaborating with others using excel.
The text was updated successfully, but these errors were encountered: