colearendt / xlsx

An R package to interact with Excel files using the Apache POI java library
https://colearendt.github.io/xlsx/
86 stars 32 forks source link

A simple question: how to just combine multiple excel files into one? #206

Open liuyanguu opened 9 months ago

liuyanguu commented 9 months ago

I thought this would be very easy using the "xlsx" package, but it seems to be not the case. The task is simply to combine several .xlsx files (some have 2 sheets, some have 1) into one .xlsx, keeping all the sheets the same. I don't want to read the data and write the data because there are also figures and pictures in those .xlsx files to be combined.

Is this something that can be done using the "xlsx" package? Any hint is highly appreciated. Many thanks again for the great package. Best,

colearendt commented 2 months ago

Apologies for the late reply here. Unfortunately, I do not think this is as straightforward as would be ideal 😢

We are using Apache POI, which is a low level Java library. Unfortunately, we are still on a very old version... (I never landed the update).

But even with newer versions, it does not look like there is a great way to solve this problem because of how different Workbooks encode a sheet. They added a cloneSheet() method within a workbook, but between workbooks is another story 😞

https://stackoverflow.com/questions/5889639/apache-poi-copying-sheets