.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

how to copy data from one excel to another excel using windows application

Posted By: kancheti     Posted Date: December 13, 2010    Points:2   Category :Windows Application
code for how to copy data from one excel to another excel file using object refference in vb.net windows application

Responses
Author: Samrat Mohanta             
Posted Date: December 13, 2010     Points: 5   

try
{
string filePath = "D:\Test.xls";
excelApp = new Excel.Application();
excelWorkBook = excelApp.Workbooks.Open(filePath);
excelWorkSheet = (Excel.Worksheet)excelWorkBook.Worksheets.get_Item(1);
excelWorkSheet.Copy(Type.Missing, Type.Missing);
excelWorkSheet = excelApp.Workbooks[2].Sheets[1];
}
finally
{
if (excelWorkBook != null)
{
excelWorkBook.Close();
}
if (excelApp != null)
{
excelWorkBook = excelApp.Workbooks.Open( "D:\Test-1.xls");
excelApp.Quit();
}
this.releaseObject(excelWorkSheet);
this.releaseObject(excelWorkBook);
this.releaseObject(excelApp);
}

Cheers....
Samrat Mohanta


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend