Saurabh Tiwari
Saurabh Tiwari

Reputation: 41

Excel.dll- Getting error on using Excel

I am using Excel.dll in my project to access data from Excel file. I have already added Excel.dll in Bin folder of my website. In my webpage i used using directive:

using Excel;

and code is

String path = "F:\\Saurabh\\database\\FMData1.xls";
FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read);
Excel.IExcelDataReader excelReader = null;       
excelReader = Excel.ExcelReaderFactory.CreateBinaryReader(stream); 

In my local server it is running fine. But when I uploaded it to the server it is giving error.

The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)

I think there is some problem with the .Net framework. Please help.......

Upvotes: 0

Views: 1835

Answers (2)

Saurabh Tiwari
Saurabh Tiwari

Reputation: 41

It was nothing wrong with the code, dll or using directive, the problem was that i placed my Bin folder at wrong place. I placed it at the root directory and now it is working very fine. Thanks to all, for giving your time and effort.

Upvotes: 0

Vignesh Kumar A
Vignesh Kumar A

Reputation: 28403

Try changing your using to:

using Excel = Microsoft.Office.Interop.Excel;

Please Refer

Upvotes: 2

Related Questions