Solved

asp.net

Posted on 2013-02-04
10
254 Views
Last Modified: 2013-02-12
1) Should Excel must be installed on the Server to use the following in asp.net

using Excel = Microsoft.Office.Interop.Excel;

if yes for what version should I go 2007 or 2010 or complete MS-Office?



2) Installing Excel will also help in sorting out the problem with the following code?

 if (fileExtension == ".xls")
                {
                    connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
                }
                else if (fileExtension == ".xlsx")
                {
                    connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";
                }

the problem is "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine" the server is 64bit. can you please also provide the solution for it? The server has Excel viewer only.

Thanks
Dinesh
0
Comment
Question by:Dinesh Kumar
10 Comments
 
LVL 23

Expert Comment

by:Roopesh Reddy
Comment Utility
Hi,

Seems like, Excel should be installed! It can be 2007/2010. So, you can also check this link - http://stackoverflow.com/questions/11448197/how-to-use-microsoft-office-interop-excel-on-a-machine-without-installed-ms-offi

For your second issue, needs to be analyzed once the first issue is solved! Mostly it will be solved!

Hope it helps u...
0
 
LVL 6

Accepted Solution

by:
manch earned 500 total points
Comment Utility
Answer to your queries :

1) Should Excel must be installed on the Server to use the following in asp.net

[Answer]
Yes, Excel will be required for it. You can have either of the MS-Office versions installed on your server and if suppose you have installed Office 2010 on your server; you have to take reference of the following dll library (to your code)

Microsoft.Office.Interop.Excel (Vesion 14.0.0.)


2) Installing Excel will also help in sorting out the problem with the following code?

[Answer]

The issue described in question occured basically due to the incompatibility of the Microsoft.Jet.OLEDB.4.0 driver in 64 bit OS.  If you are using Microsoft.Jet.OLEDB.4.0 driver in a 64 bit server, you have to force the application to build in in 32 bit mode; which causes other part of code to break.

Fortunately, now Microsoft has released a 64 bit compatible 2010 Office System Driver which can be used as replacement for the traditional Microsoft.Jet.OLEDB.4.0 driver. It works both in 32 bit as well as 64 bit servers. But this driver is in BETA.

You can download this driver from Microsoft Access Database Engine 2010 Redistributable.
0
 
LVL 19

Expert Comment

by:Rimvis
Comment Utility
Hi  meetDinesh,

1) Short answer is yes, you have to install Excel to use interop. The slightly longer answer is that you shouldn't use Office automation on server-side applications.
http://support.microsoft.com/kb/257757

2) There is no Jet driver for 64bit systems. You could use it, but you'll have to switch entire ASP.NEW application to 32 bit mode
https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/55cd5e11-49a9-4158-8b1f-7f2aa4ad2f07.mspx?mfr=true

But why are you switching connection string here? I think you can use ACE driver to read XLS files.
0
 

Author Comment

by:Dinesh Kumar
Comment Utility
Fine.

manch: I tried to install Microsoft Access Database Engine 2010 Redistributable http://www.microsoft.com/en-in/download/details.aspx?id=13255
but it says first you need to uninstall 32 bit version... ( I used AccessDatabaseEngine_x64.exe)

Rimvis: I will try your second solution.

roopeshreddy: Ok.

On server its IIS7.
0
 

Author Comment

by:Dinesh Kumar
Comment Utility
The client has installed the 2007 excel but without the serial key and told that its fully functional.

but I am finding the following error:

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

it was coming before also when Excel 2007 was not installed.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 23

Expert Comment

by:Roopesh Reddy
Comment Utility
Hi,

I doubt whether it's installed properly!  Install the updates as well!!!
0
 

Author Comment

by:Dinesh Kumar
Comment Utility
I checked it saving the file and then I can open it as well in Excel.
0
 
LVL 23

Expert Comment

by:Roopesh Reddy
Comment Utility
Hi,

Check this article on how insall Office Primary Interop - http://msdn.microsoft.com/en-us/library/kh3965hw(v=vs.100).aspx

Hope it helps u...
0
 

Author Comment

by:Dinesh Kumar
Comment Utility
I will check this out but FYI I am using .net framework 2.0
0
 

Author Closing Comment

by:Dinesh Kumar
Comment Utility
I tried 64bit drivers on the server and for it oledb drivers were giving error so I switched to ACE.OLEDB drivers only.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now