Forum Discussion
Mamidre Tomoe
Aug 16, 2017Copper Contributor
How to combine two Excel spreadsheets into one Sheet, side-by-side in C#?
Hi,
I am currently doing a project that requires Excel. I am trying to combine information from two Excel spreadsheets together and save it into a new file so that I can convert it into a Word document for Mail Merge.
So far, I have found Solution 1 from https://www.codeproject.com/Tips/715976/Solutions-to-Merge-Multiple-Excel-Worksheets-int to work, however the result produced in the picture is not the same as the one that I have generated (the spreadsheet generated on my end stacks both files on top of one another instead of side-by-side like in the picture).
I would like to see if there is a way to produce the desired result that I want (which is two Excel spreadsheets merged together, separated into two columns).
Any help would be appreciated. Would also appreciate some C# code as well.
Thank you.
2 Replies
Sort By
Hello,
it's hard to answer your question without seeing the structure of the two workbooks and the desired result of the merge.
Excel has Power Query as a free add-in for 2010 and 2013, called Get and Transform in Excel 2016. It is easy to use Power Query to merge files. You don't need code, no C# or Visual Studio, just a good understanding of the logic you want to apply and the ability to click icons in the ribbon.
If you can share some sample files and the desired merge result, things can be arranged.
- Mamidre TomoeCopper Contributor
Hi,
Attached are two example documents that I want to merge (example excel has the two documents I want to merge. Note that the two examples would be different Excel files.), the result I got (actual result) and the result that I want (desired result).
I am aware of Power Query, but I have to do everything in Visual Studio C# as I need to generate the merged document with a button click on the Windows Form which will also convert the merged document into a Word document at the same time. This is therefore the reason why I am not using Power Query, and using Visual Studio C# instead.