I'm using the basic functions of openxlsx package for writing data on excel file. When I use .xlsx files for writing data, there is no problem. When I try to use .xlsm (files with macro) for writing data, after saving the .xlsm file, there is a duplication of sheets in the Vba Project and these new sheets are empty.
My code is as follows:
OutputBook = loadWorkbook("DataImportOutput.xlsm")
writeData(OutputBook, "Database", MyData, rowNames = TRUE, startCol=1, startRow=1)
saveWorkbook(OutputBook, "DataImportOutput.xlsm", overwrite = TRUE)
At the end of the R code, "DataImportOutput.xlsm" has a duplication of sheets in is Vba Project. Using the same file, but without macros (.xlsx), there is no duplication.
Why does this duplication of worksheets happen? There is a method to avoid this duplication of sheets with .xlsm files?