Search code examples
rexcelfile-conversionopenxlsx

How to convert xls to xlsx using R


I want to convert a bunch of xls files to xlsx in R so I can use the openxlsx package to overwrite in specific cells.

Up until now, I've been changing the format manually by opening each xls file and then saving them as .xlsx. As you can imagine this is really tiresome and it is kind of manageable now that I have less than 10 files, but I am expecting to have a lot more of these files.

I was wondering if someone has found a way of doing this automatically. I am using R 4.2.1 so the RDCOMClient package is not an option (I have read that this could be done easily with that package but it is not available anymore)

Edit I am working with tables within an Excel sheet and I need to maintian the format hence the overwriting.

I am familiar with the openxlsx package and my main issue is getting the Workbook objects out of the xls files. That is why I want to convert them into xlsx files.


Solution

  • In case someone else is also interested, I really didn't figure out how to do this in R but I did found this https://www.extendoffice.com/documents/excel/1349-excel-batch-convert-xls-to-xlsx.html#a2 and I can keep the exact same format from the original file.