473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Creating Excel spreadsheet

Hello,
I'm getting an "Access Denied" error when I hit the line of code...

Excel.Application oXL = new Excel.Application();

From what I've read, you can get around this by putting the file (where this
code is) in a separate directory and also putting its own web.config in this
separate directory with this line in it...

<identity impersonate="true"/>

My question is simple...how can you get the .NET project (solution) to add
(use) a file not in the home directory? When I add this file (in the
separate directory) to the solution, .NET copies the file into the main
project directory and uses it.
Is there a way to do this? Am I missing something?

Thanks in advance to anyone who can help. :)
Nov 17 '05 #1
4 3182

You should never do Office automation in a web application. There are
many other options for generating Excel content that work for most
situations.

From MS:

"Microsoft does not currently recommend, and does not support,
Automation of Microsoft Office applications from any unattended,
non-interactive client application or component (including ASP, DCOM,
and NT Services), because Office may exhibit unstable behavior and/or
deadlock when run in this environment."

http://support.microsoft.com/default...b;en-us;257757

That article also gives links to alternatives.

HTH,

Sam
On Fri, 13 May 2005 13:07:44 -0500, "Randy" <te**@temp.com> wrote:
Hello,
I'm getting an "Access Denied" error when I hit the line of code...

Excel.Application oXL = new Excel.Application();

From what I've read, you can get around this by putting the file (where this
code is) in a separate directory and also putting its own web.config in this
separate directory with this line in it...

<identity impersonate="true"/>

My question is simple...how can you get the .NET project (solution) to add
(use) a file not in the home directory? When I add this file (in the
separate directory) to the solution, .NET copies the file into the main
project directory and uses it.
Is there a way to do this? Am I missing something?

Thanks in advance to anyone who can help. :)


Nov 17 '05 #2
While you can do what you're trying to do with a Windows Forms application, a
web application will only automatically look to resolve assembly references
in only a couple of places. The bin directory (and any subdirectories) and
the GAC. If you have the class placed into COM+, ASP.NET will find it there
too, but I believe that the COM+ assemblies are in the GAC, so that doesn't
really could.

That having been said, I don't know for sure if that is your problem. I
believe I've seen access denied errors in this situation where the ASP.NET
user hadn't been granted Launch permissions for Excel. You would be able to
grant this permision using the DCOM Config tool.

Hope that helps.

Bruce Johnson [C# MVP]
http://www.objectsharp.com/blogs/bruce

"Randy" wrote:
Hello,
I'm getting an "Access Denied" error when I hit the line of code...

Excel.Application oXL = new Excel.Application();

From what I've read, you can get around this by putting the file (where this
code is) in a separate directory and also putting its own web.config in this
separate directory with this line in it...

<identity impersonate="true"/>

My question is simple...how can you get the .NET project (solution) to add
(use) a file not in the home directory? When I add this file (in the
separate directory) to the solution, .NET copies the file into the main
project directory and uses it.
Is there a way to do this? Am I missing something?

Thanks in advance to anyone who can help. :)

Nov 17 '05 #3

"Randy" <te**@temp.com> wrote in message
news:uy****************@TK2MSFTNGP09.phx.gbl...
Hello,
I'm getting an "Access Denied" error when I hit the line of code...

Excel.Application oXL = new Excel.Application();

From what I've read, you can get around this by putting the file (where
this code is) in a separate directory and also putting its own web.config
in this separate directory with this line in it...

<identity impersonate="true"/>

My question is simple...how can you get the .NET project (solution) to add
(use) a file not in the home directory? When I add this file (in the
separate directory) to the solution, .NET copies the file into the main
project directory and uses it.
Is there a way to do this? Am I missing something?

Thanks in advance to anyone who can help. :)

This has nothing to do with code file locations, the web application
identity (aspnet or the impersonating user) has no rights to start and
access Excel.
You need to run dcomcnfg and grant Launch and Access privileges to the
aspnet user for Excel.
Note that you shouldn't use impersonation here as you'll have to include all
possible users to the list.
Note also that using Office applications from web applications isn't
supported and (in general) doesn't work as you would expected, Office is a
personal productivity tool to be used from a client, it isn't designed to
run server side.

Willy.


Nov 17 '05 #4
what are you trying to do with excel? maybe there is a better way

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
"Randy" <te**@temp.com> wrote in message
news:uy****************@TK2MSFTNGP09.phx.gbl...
Hello,
I'm getting an "Access Denied" error when I hit the line of code...

Excel.Application oXL = new Excel.Application();

From what I've read, you can get around this by putting the file (where
this code is) in a separate directory and also putting its own web.config
in this separate directory with this line in it...

<identity impersonate="true"/>

My question is simple...how can you get the .NET project (solution) to add
(use) a file not in the home directory? When I add this file (in the
separate directory) to the solution, .NET copies the file into the main
project directory and uses it.
Is there a way to do this? Am I missing something?

Thanks in advance to anyone who can help. :)

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have...
0
by: volume | last post by:
Hi all, In an effort to try to impress the boss, I would like to log accounting information to an Excel spreadsheet using C# and .NET. This would be a mockup only, not a real solution - yet! We...
3
by: A.M | last post by:
Hi, Using ASP.NET/VB.NET and SQL Server backend, I need to return calculation results to user as an Access MDB file or Excel XLS sheet. What would be the best way to create a MDB or XLS file...
14
by: Raoul Snyman | last post by:
Hi, I need to be able to programatically create excel spreadsheets in ASP.NET (C#), WITHOUT having MS Office on the server. Does anybody have any advice/links/whatever for me? Thanks in...
9
by: Gordon | last post by:
Hello again, Sorry to repost this request, but I'm under a bit of pressure to find a quick solution. All I basically want is an automatically updating link (OLE, not DDE) between a control in...
3
by: Ken Hall | last post by:
Is it possible to create an Excel spreadsheet using VB.NET without opening the Excel application or having to have the Excel application on the operating computer? KH
1
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
1
by: Mitch | last post by:
I am using Access to create an Excel spreadsheets with graphs related to rows on the sheet1 to the graph on sheet2. I am using the same data but different subsets of the data to make different...
4
by: zacks | last post by:
I have an application that can read an Excel spreadsheet on a computer that doesn't have Excel installed on using the Jet ODBC 4.0 driver. I know need to modify the application to also be able to...
2
by: vijayarl | last post by:
Hi Everyone, Am trying to collate the individual xls files into a single xls file.i have written this code. use strict; use Spreadsheet::WriteExcel; use Spreadsheet::ParseExcel; use...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.