问题
I am using openxlsx to Write to existing xlsx file without altering the formatting.
my file is "razii.xlsx. I have done the following tasks:
library(openxlsx)
df1<-read.xlsx("C:/data/razii.xlsx",startRow = 3)
Next, I have analysed two columns using 'razii.xlsx' using R codes and I called it df2.
Now I want to write to the existing xlsx file without altering the formatting. I have used the following codes:
wb <- loadWorkbook(file = "C:/data/razii.xlsx")
addWorksheet(wb, "Razii")
x <- df2
writeData(wb, "Razii", x, startRow = 3, rowNames = TRUE)
saveWorkbook(wb, "C:/data/writeDatarazii.xlsx", overwrite = TRUE)
However, I get a corrupted file. Have I missed anything?
来源:https://stackoverflow.com/questions/59911202/i-get-a-corrupted-file-when-i-use-openxlsx