Excel Problem

G

Guest

Hi,
I have a ASP.net application which takes excel sheet as input.It retrieves
the data from the excel sheet and using that data it generates reports.
On my PC everything is working fine.But if somebody access my application
other than localhost,i.e something like
http://MyMachinename/MyapplicationName/Report.aspx
application is throwing the error "Rejected Safe Mode action : Microsoft
Office Excel."

I'm using code like this
Imports Excel = Microsoft.Office.Interop.Excel
Dim objExcel As Excel.Application
Dim objExcelWorkBook As Excel.Workbook
Dim objExcelWorkSheet As Excel.Worksheet

Can anybody please help me in resolving this?

Thanks in advance
 
M

Mark Fitzpatrick

Do you have all the interop assemblies loaded on the server? Using Excel
server-side is still troublesome at best and highly problematic. If you're
just querying the spreadsheets, have to tried simply opening a database
connection to the spreadsheet? A lot of people don't think of using Excel as
a datasource just like any other database, but it's possible. Check out
http://www.connectionstrings.com/ for the proper way to connect to it.
 
L

Laurent Bugnion

Hi,

Mark said:
Do you have all the interop assemblies loaded on the server? Using Excel
server-side is still troublesome at best and highly problematic. If you're
just querying the spreadsheets, have to tried simply opening a database
connection to the spreadsheet? A lot of people don't think of using Excel as
a datasource just like any other database, but it's possible. Check out
http://www.connectionstrings.com/ for the proper way to connect to it.

I concur, using Excel as a DB works fine. I have a code example here:

http://geekswithblogs.net/lbugnion/archive/2006/08/25.aspx

HTH,
Laurent
 
M

Mark Rae

Imports Excel = Microsoft.Office.Interop.Excel
Dim objExcel As Excel.Application

This is without doubt one of the worst things you can do in terms of
scalability, performance and robustness. Microsoft themselves not only
strongly advise against it but they will also not support any solution which
uses it: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

You've already encountered the first major problem - I'm afraid it's only
likely to get worse...

There are several options:

1) As others have suggested, consider using ADO.NET to treat the Excel
worksheet as any other relational data source

2) Use a 3rd-party tool like this:
http://www.aspose.com/Products/Aspose.Cells/Default.aspx Also, you would do
well to have a read of their "Why Not Automation" page.

3) If the Excel spreadsheets can be saved in XML format first, they can be
consumed by ASP.NET just like any other XML document
 
G

Guest

Hi Mark,
Thanks for the reply.
Yes, i'm using the following OLDDBConnection string for the excel.

Dim xlconn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended
Properties=""Excel 8.0;HDR=Yes;IMEX=1"";Data Source=" + filePath + "").

When i'm running through VS.net IDE i'm not getting any error.But if i'm
accessing through other machine.I'm getting the error "Rejected Safe Mode
action : Microsoft
Office Excel."
The DLLs for Microsoft.Office.Interop.Excel is under GAC.

Thanks
Srinivas
 
L

LosManos

hejdig.

Is it a path problem? Do you use <input type="file... and read the file as
a stream?

FWIW

/OF

-----8<------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top