Click here to Skip to main content
16,015,658 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
As i am new to C# programing, i was trying this code line
Microsoft.Office.Interop.Excel.Worksheet workSheet = (Microsoft.Office.Interop.Excel.Worksheet)workBook.ActiveSheet;

This gives me access to the active sheet. But is there any way i can access a worksheet of a particular name or any other worksheet in the file. How is the worksheet selection done here and how can i access other work sheets ?
Posted

Hai...

U can mention the Sheet name of Excel in a query to access the data. Plz go through this link. It will be helpful...


http://support.microsoft.com/kb/316934
 
Share this answer
 
try something like this


<pre><code>
Excel.Worksheet tempSheet = (Excel.Worksheet)workBook.Sheets[index of sheet or Sheet Title usually "Sheet1", 'Sheet2", "Sheet3" etc];
</code></pre>
 
Share this answer
 
v2
Comments
asjadazeez 29-Jun-10 5:54am    
Thanks this seems to work.

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