Physically open excel file


Does anyone have any examples where I open an excel file and copy the cell content from it to a newly created excel file ?

Hi @john01!

It sounds like you're trying to control Excel from within R? If that's the case, one option is RDCOMClient (note that it's not yet available for R 3.6). Its main documentation page has several examples showing how it can be used. If you've ever done any Office automation outside of R, it will be fairly familiar material. If not, it might be slow going.

If you explain a little bit more about the problem you're trying to solve, then that might suggest other solutions?

What I am trying to do really is to open an excel file and copy cell content, its formatting into another workbook's excel cell with the same formatting and content. The conditions and rule base on why I am doing that is too long to elaborate. I am thinking of using SQL statements in data frame to rationalize this. Python can open excel files I have done it. I guess in R this is the only way.

Can R upload excel cell contents and formatting into data frame, table, or clipboard ?
Excel cell contents, and formatting such as sentences that are bold, italic, underline, and hyperlink etc.

I just tried to install the two packages.

RDCOMClient and

It didn't work. I couldn't install it.

There are several R packages that can read data and cell formatting from Excel, several packages that focus on writing Excel sheets with data and (sometimes) formatting, and some packages that do both. This blog post is a bit old, but it covers the major roundtrip contenders. There's a fairly exhaustive list here, as well.

tidyxl can be helpful for analyzing the structure and formatting of an Excel spreadsheet, though its focus is not on round-trip read/write:

Importing and then exporting always carries the risk of losing something, but only you will be able to tell how big of a problem this might be based on the complexity of the spreadsheets you are working with.

If you want help with this, you'll need to provide more information on what happened when you tried to install. Since package installation trouble is wandering away from the original question, that would probably be best put in its own topic, with a link here.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.