Hello, The simply solution is to use OleDb as all you are doing is obtaining data from a sheet in one file and inserting data into another file to a specific sheet. I don't have an example but do have an article with several demo projects that show extracting and inserting data via OleDb. With that said I will indicate up front that the connections must be setup properly and in the above link you will find helper functions to assist with this. Study how in the connection strings I setup HDR and IMEX. As mentioned, a third party component library may be used or Excel automation but for this operation would steer you away from Excel automation until you understand the Excel model and about properly creating and disposing of memory else it is extremely possible you will run into memory issues on your development or worst yet a production box.
Be forewarned of a handful of lines to do this task with Excel automation as many are on the web that fail to clean up afterwards. Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions.
Hello, The simply solution is to use OleDb as all you are doing is obtaining data from a sheet in one file and inserting data into another file to a specific sheet. I don't have an example but do have an article with several demo projects that show extracting and inserting data via OleDb. With that said I will indicate up front that the connections must be setup properly and in the above link you will find helper functions to assist with this. Study how in the connection strings I setup HDR and IMEX. As mentioned, a third party component library may be used or Excel automation but for this operation would steer you away from Excel automation until you understand the Excel model and about properly creating and disposing of memory else it is extremely possible you will run into memory issues on your development or worst yet a production box.
Open Microsoft Excel. Click the 'File' tab and select 'Open.' Browse to the spreadsheet to copy and double-click the file name, opening the spreadsheet in the main work view. Open another instance of Microsoft Excel by double-clicking the icon again. If you have dual monitors, drag one copy of Excel onto the second monitor. Transfer Data from One Spreadsheet to Another For each example, consider that we have two sheets: Sheet 1 and Sheet 2 and we would like to transfer from cell A1 of Sheet 1 to cell B1 of Sheet 2. Using the + Symbol in Excel Start by selecting the target cell (in our case B1 of Sheet 2) and typing in the + symbol.
Be forewarned of a handful of lines to do this task with Excel automation as many are on the web that fail to clean up afterwards. Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile but do not reply to forum questions. I would recommend the EPPlus package. From the Package Manager Console: PM Install-Package EPPlus I find this makes reading and writing Excel files very easy. Hope this helps, Dean Dean, the rule of thumb here is for you not to mark your reply as proposed answer but for others to judge if the reply is worthy.
So in the future please refrain from this action. Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.
Contact via my webpage under my profile but do not reply to forum questions.