Solved

asp.net

Posted on 2013-02-04
10
258 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
ID: 38853957
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
ID: 38853959
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
ID: 38853968
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:Dinesh Kumar
ID: 38854124
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
ID: 38856145
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
 
LVL 23

Expert Comment

by:Roopesh Reddy
ID: 38856480
Hi,

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

Author Comment

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

Expert Comment

by:Roopesh Reddy
ID: 38858193
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
ID: 38858872
I will check this out but FYI I am using .net framework 2.0
0
 

Author Closing Comment

by:Dinesh Kumar
ID: 38879591
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

856 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