I get a corrupted file when I use Openxlsx

孤者浪人 提交于 2020-02-07 02:36:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!