Reputation: 33
I have 3 Excel files to manipulate and I want to generate a single Excel file based on them. I need to join the third column of the first file with the first column of the second and third Excel file. What would be the best way to do it in C#.
Upvotes: 3
Views: 437
Reputation: 19340
Believe it or not, you may don't have a big project on your hand. If you use Microsoft.Ace.OleDb
provider to connect to your excel, you will be on your way to success. Check this To create a new file we simply provide the name of a non existent file in the connection string. This will create a new file.
So, you can create and read Excel files with provider above. This is thin, nothing like interop
, and can be safely used on server, like web server.
Since you know how to use your provider [it is literally just like DB], the logic below is - how to join data
DataTable
of a DataSet
Upvotes: 1
Reputation: 355
If you work with OpenXML files (.xlsx) you can use the Microsoft OpenXML SDK. It is a library that allows you to open or create .docx, .pptx and .xlsx files: https://msdn.microsoft.com/en-us/library/office/bb448854.aspx
Otherwise you can automate Excel using C#: https://support.microsoft.com/en-us/kb/302084
Upvotes: 0