Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Can I ask for any reference or any sample code on how to append two different excel files?
Example scenario:
I have a tool and I need to get/copy the data (e.g one whole row B) from the excel file save as translation request.xls and paste it to the different excel file save as Translation Dictionary.xls using the tool.

Can I ask for your help regarding with this. Any suggestions will much be appreciated.

Thankies!
'pao :3
Posted
Comments
Weepre 5-Jul-16 9:29am    
as 'bsb25' suggested below one approach would be to use excel interop from your C# code, however another approach would be to use an excel's library for C#.
For example something like the following:

ExcelFile requestBook = ExcelFile.Load("Translation Request.xls");
ExcelFile dictionaryBook = ExcelFile.Load("Translation Dictionary.xls");

// Copy second row from "Sheet1" in "Translation Request.xls" file
// into a "Sheet1" in "Translation Dictionary.xls" file
// onto an "A2" position (the beginning of the second row).
requestBook.Worksheets["Sheet1"].Rows["2"].Cells.CopyTo(
dictionaryBook.Worksheets["Sheet1"], "A2");

dictionaryBook.Save("Translation Dictionary.xls");

You can also refer to this article about reading excel files from C# application.

1 solution

 
Share this answer
 
Comments
jcosep 13-May-11 3:50am    
thanks i'll check it out!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900