Click here to Skip to main content
15,906,097 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I m using .net 2005 i m trying to put name space
using Excel;
for excel datasheet import and export in my application but it is showing error in name space.
what should I do ?
Please help

Thanks & regards
Indrajit dasgupta
Posted
Comments
Ankit Rajput 27-Apr-11 2:45am    
Can you please provide the error detail.

You probably need to include a reference to the Excel Interop dll (Microsoft.Office.Interop.Excel.dll).
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 27-Apr-11 3:00am    
It's good you mention DLL (you should have said assembly; moreover, in CAG is it not named by DLL... because it's strongly named). My 5.

Also, name space can be retrieved using VS.

I explain that in general terms, please see my answer.
--SA
Hi,

You can try one thing
use this syntax
using Microsoft.Office.Interop.Excel;


For this you need to add refrence of
"Microsoft.Office.Interop.Excel"

Regards
AR
 
Share this answer
 
Comments
Abhinav S 27-Apr-11 2:49am    
He also needs to add a reference to the dll.
Ankit Rajput 27-Apr-11 2:53am    
I have already maintioned the Refrence name.
Only the difference is, I have maintioned it as .Net will show you
Sergey Alexandrovich Kryukov 27-Apr-11 3:02am    
Best answer so far (mine, too :-) because you mention assembly and not DLL (important for CAG).
Also, name space can be retrieved using VS.

I explain that in general terms, please see my answer.
--SA
Ankit Rajput 27-Apr-11 5:00am    
thanks
There are no any problems with any name spaces in any version of .NET.

The only problem is failure to reference assemblies required by your project. Usually, when a compilation fails, it tells you what assembly should you add to the reference list of your project. It is not the case if it is not the GAC assembly or a registered COM component.

The assembly you need is in GAC, its name is "Microsoft.Office.Interop.Excel".

[EDIT]
(Ankit mentioned it.)

When an assembly reference is added, click on its node in Project Explorer. It opens the tree of references where you can browse and find out your name spaces. Use what you need in "using".

—SA
 
Share this answer
 
v3
Comments
Ankit Rajput 27-Apr-11 3:23am    
Good explanation. My 5
Sergey Alexandrovich Kryukov 27-Apr-11 3:46am    
Thank you, Ankit. And thank for your answer which I referenced because it did not have those inaccurate items I commented in other answers.
--SA
Try:
using Microsoft.Office.Interop.Excel;
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 27-Apr-11 2:58am    
You should have mentioned the assembly first of all, as others did. Name space can be found when it is referenced.
I explain that in general terms, please see.
--SA
OriginalGriff 27-Apr-11 3:04am    
You are probably right, I should have suggested adding a reference first.

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