I am writing a function whose output is an excel file and I need to overwrite the excel file if already existing (I personally don't think this is the best solution, but the person I am writing the function for wants so). I am using the XLConnect package and using loadWorkbook(..., create=createifnot)
with a createifnot
logical variable works perfectly, but the format of the overwritten file looks terrible. Example:
Create new file:
Overwrite old file:
The problem doesn't seem to be addressed in the XLConnect vignette.
Any suggestions? Thanks!
Try clearing the table in excel first with the function: clearRange(wb, sheet = "sheetname",coords = aref2idx(c(coordinates in style:"F26:PGI29")))
. And then overwrite the cells with the new data.
sheetname = name of the sheet writing to. coordinates = the range in the excel file.
I hope this is helpfull