?
Solved

asp.net

Posted on 2013-02-04
10
Medium Priority
?
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1500 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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

741 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