Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
the following statement was used to copy a excel worksheet in C#, from one workbook to another. It was using Miscrosoft.Office.Interopt.Excel (.NET 1.0) but I now want to convert it to .NET 3.5 the code is now broke. How would I convert this statement to work with .net 3.5. BTW this is in a ASP.net Web app.
C#
wbkSource.Sheets("Source").Copy(wbk.Sheets(1));   Broke here!

This statement fails with this error
Non-invocable member 'Microsoft.Office.Interop.Excel. Workbook.Sheets' cannot be used like a method.
Posted
Updated 5-Dec-11 12:03pm
v2
Comments
Orcun Iyigun 5-Dec-11 17:46pm    
Well I am not quiet certain but can you replace your round brackets to square ones?
wbkSource.Sheets("Source").Copy(wbk.Sheets[1]);

1 solution

Tried that, Didn't work. Tried this and it worked! A trial and error guess.

C#
wbk.Sheets.Copy(wbkSource.Sheets["Source"], Type.Missing);
 
Share this answer
 
v2

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