I'm currently grappling with an issue while merging two Excel workbooks (`array1` and `array2`)
I'm currently grappling with an issue while merging two Excel workbooks (
array1
and array2
). The challenge arises when I add sheets from array2
to array1
using the following code:
- I'm trying to merge two Excel workbooks (array1
and array2
), and while the sheets from array1
are created successfully, they seem to be empty when additional sheets from array2
are added. The perplexing part is that the sheets from array2
are being integrated correctly, but the corresponding sheets from array1
appear to lose their data.5 Replies
might be some bug in the package you are using. Do their docs have anything about merging workbooks?
Excel workbooks are very complicated, and if you're using OpenXML directly you need to handle that complexity yourself
For example, sheets can reference data kept in common locations (IIRC?) in order to store things more efficiently
If you can, definitely use a package which makes life a bit easier. I don't know whether any of them support merging though... Look at ClosedXML, NPOI, and others
I didn't find any
Seems I'm close to find the solution but the only problem I facing now is If I'm returing the right data return package1.GetAsByteArray();
And the solution bellow return just the sheets of the first workbook but the sheets of the second one not created
That's not surprising, as you never save any of the changes to workbook1
I already this
package1.Save();
after Iterate through sheets in workbook2 but nothing changes
@canton7 note I'm call the result here