LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default copy data from one excel to another in Visual C#

Guys

I need to copy data from one excel file to other. Am doing this in
asp.net with c# as backend code. Do I need to two excel Application
objects? No matter if I use two excel objects or one, I am ending up
with one excel object in memory even after closing them. Whats the best
way to do this without leaving any Excel apps around? Please help.

Heres what my code looks like:

Excel.Application exclApp = new Excel.ApplicationClass();
Excel.Workbook... srcWb = Open("source.xls",...)
Excel.WorkSheets srcSheets
Excel.Worksheet srcSheet

Excel.Workbook dstWb = open("dest.xls",....)
Excel.Worksheets dstSheets
Excel.Worksheet dstSheet..

dstSheet.range = srcSheet.range;

cleanup..

I call ReleaseComObject() on all above objects and finally.

exclApp.Quit();
GC.Collect();

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual to copy format one row down when data entered Jeremy Excel Discussion (Misc queries) 1 November 5th 09 04:20 PM
copy and paste visual cells only in Excel MermaidHunter Excel Discussion (Misc queries) 2 October 1st 07 09:54 PM
copy and paste (visual basic) ian123 New Users to Excel 1 June 8th 06 12:22 AM
Passing a range of data to a function - Excel - visual basic dochoa Excel Programming 2 February 2nd 06 08:13 PM
Link or Copy Excel Data to Calendar (for scheduling) for Visual Aid supafreeza Excel Discussion (Misc queries) 1 July 10th 05 04:47 AM


All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"