Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to export data?

Status
Not open for further replies.

gd082

Programmer
Mar 12, 2002
42
0
0
BE
We'd like to export data from an asp.net-page to excel. We tried this :

Dim oExcel as Excel.application
Dim OBook as Excel.Workbook
Dim oSheet as Excel.Worksheet

oExcel = New Excel.Application()
oBook = oExcel.Workbooks.Add
oSheet = oBook.Worksheets(1)
oSheet.Cells(1,1) = "hello"
oExcel.Visible = True
oExcel.UserControl = True

But we get an error :
Acces denied.
The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '(machinename)\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

Can anyone help us please?

Thx a lot

greetz, gd082
 
I'm administrator of the computer, I've given myself all the rights possible on Excel, ...

Still it's always the same :

Exception Details: System.UnauthorizedAccessException: Access is denied.

The ASP.NET process is not authorized to access the requested resource. For security reasons the default ASP.NET process identity is '{machinename}\ASPNET', which has limited privileges. Consider granting access rights to the resource to the ASP.NET process identity.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the "{machinename}\ASPNET" user. Highlight the ASP.NET account, and check the Write box in the Allow column.

I did everything they asked me to do, no way it's going to work... I'm getting nuts 'bout microsoft.
 
Not sure if this helps or not but in the VB.NET forum a somewhat similar problem was presented.

thread796-264809

It seems that you need to add an underscore before the application word. Rather than
Dim oExcel as Excel.application
it is like this
Dim oExcel as Excel._application

hope this helps [peace]
 
You don't need to add permissions to teh Administrator, but to the ASPNET local user of your computer.
Make sure that All the folders that you are working with, have full permission to the ASPNET user.

hth
 
gd082,

I am having the same problem as you are. Have you found a resolution yet?

Regards,
natgreen
 
Function Excel()
Response.ContentType = "application/vnd.ms-excel"

Response.Charset = ""
Me.EnableViewState = False

Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

datagrid1.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()

End Function

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Excel()
End Sub

---used this to export to excel from a datagrid in ASP.NET
 
Make sure in your web.config file that you do not have the line:

<identity impersonate=&quot;true&quot;/>

As this will screw up your anonymous access...

Chris
 
I know that the permissions need to be set to allow the local asp.net user to gain access to the requested resource(excel) but I do not know which files to set the permissions on. I've granted permissions for excel but I still receive the same error. WHAT DOES THE LOCAL ASP>NET USER NEED TO HAVE PERMISSIONS ON?
 
AS you did, I tried to put the permission on WinWord.exe for {computername}/ASPNET without success..
So, WHAT DOES THE LOCAL ASP>NET USER NEED TO HAVE PERMISSIONS ON? -
(if you get System.UnauthorizedAccessException: Access is denied. when using word.dll on ASPnet Application)

Or is there an other solution ?
 
Check out what I said above, I had the exact same problem - all my permissions were right but I still kept getting &quot;Access Denied&quot;, and the whole &quot;check permissions&quot; message. Turns out I had <identity impersonate=&quot;true&quot;/> in my web.config while I had my IIS Webs set to &quot;Anonymous&quot;. This may be the problem. Chris says: &quot;It's time for a beer.&quot;
 
This sounds good for an intranet - where I can give permission to local users. How about over the internet? How can I get an interactive Word session going on the client side?
 
How can i grant permission to ASPNET user? I im not sure if this user exist, how can I make or add this user (ASPNET)
 
I was able to aspnet user on the persimmission on the excel file and i dont have the identity impersonate = true in the web.config.Im still experiencing the same problem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top