Re: how to kill EXCEL component in taskManager which is in memory

From: hari krishna (harikrishna_at_discussions.microsoft.com)
Date: 09/16/04


Date: Thu, 16 Sep 2004 03:29:01 -0700

hi Steve,
 Thank you very much for the answer.
I have read the examples on the aspnetpro.com page and tried the first two
examples through ASP.Net.
for the second example whose heading is 'Simply Compatible: Tab Delimited
Format'.
The code executed successfully but it didnot generate any xl file.
In the code for response.addheader i gave the file name with path though it
did not generate xl file.
  Response.AddHeader("Content-Disposition", "inline;filename=c:\testHKVG.xls")
The code for above is like this below:
'------------------------------------------------------------
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim scon As SqlConnection = New SqlConnection("server=10.109.30.102;
UID=vf99; Pwd=lamap; database=dev;") ' Trusted_Connection=No")
        scon.Open()
        Dim adapter As SqlDataAdapter
        Dim dt As DataTable
        Dim ds As DataSet

        adapter = New SqlDataAdapter("select * from tb_vf_property", scon)
        ds = New DataSet
        adapter.Fill(ds, "dt")
        dt = ds.Tables("dt")

        ''Dim dt1 As DataTable
        ''dt1 = dt
        ''dt1 = CType(Application.Item("dt"), dt)

        Response.ContentType = "application/ms-excel"
        Response.AddHeader("Content-Disposition",
"inline;filename=c:\testHKVG.xls")

        Response.Write(ConvertDtToTDF(dt))
    End Sub

    'Converts a DataTable to Tab Delimited Format
    Private Function ConvertDtToTDF(ByVal dt As DataTable) As String
        Dim dr As DataRow, ary() As Object, i As Integer
        Dim iCol As Integer

        'Output Column Headers
        For iCol = 0 To dt.Columns.Count - 1
            Response.Write(dt.Columns(iCol).ToString & vbTab)
        Next
        Response.Write(vbCrLf)

        'Output Data
        For Each dr In dt.Rows
            ary = dr.ItemArray
            For i = 0 To UBound(ary)
                Response.Write(ary(i).ToString & vbTab)
            Next
            Response.Write(vbCrLf)
        Next
    End Function
''---------------------------------------------------------

for 1st example whose heading is 'Make Excel Do the Work',
i got the below error at the line: Dim oExcel As New Excel.Application() in
aspx form.
pls suggest me how to solve it.

Access is denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user (typically
IUSR_MACHINENAME) or the authenticated request user.

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
appropriate user or group. Highlight the ASP.NET account, and check the boxes
for the desired access.

Source Error:

Line 28: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Line 29:
Line 30: Dim oExcel As Excel.Application = New Excel.Application
Line 31:
Line 32: Dim oBooks As Excel.Workbooks, oBook As Excel.Workbook
 

Source File: E:\Inetpub\wwwroot\WebApplication1\WebForm3.aspx.vb Line: 30

Stack Trace:

[UnauthorizedAccessException: Access is denied.]
   WebApplication1.WebForm3.Page_Load(Object sender, EventArgs e) in
E:\Inetpub\wwwroot\WebApplication1\WebForm3.aspx.vb:30
   System.Web.UI.Control.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()

 

"Steve C. Orr [MVP, MCSD]" wrote:

> It's not really a great idea to use Excel from ASP.NET. Excel just wasn't
> designed for such a task, and that's why you are experiencing flakey
> behavior.
> Here's some best practices on the subject of exporting to Excel from
> ASP.NET:
> http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp200309so_l.asp
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://Steve.Orr.net
>
>
> "hari krishna" <harikrishna@discussions.microsoft.com> wrote in message
> news:3557C02B-11E3-4EE7-8131-8924ACF49025@microsoft.com...
> > hi,
> > I am generating excel reports through vb.Net. After creating
> > excel.application and the report is generated, each report leaves Excel in
> > memory. I can see them in task manager in Process tab (as EXCEL). So the
> > memory has been taken by excel objects and memory is being full. i want to
> > delete or kill this objects which are in memory. i wrote the code as
> > 'myexcel.quit()' , myexcel=nothing. but still it is in memory.
> > pls tell me how to do.
> > rgds,
> > Hari.
>
>
>



Relevant Pages

  • Re: Certificate server
    ... that the machine had too little memory. ... I have issued numerous certs from this instance via the ... Are you able to request certificates using certreq? ... within the IIS manager, but when I create a request from virtual ...
    (microsoft.public.windows.server.security)
  • Re: excel problem in asp.net
    ... The code you are using creates an excel workbook file in memory as an object ... Everything you're showing here happens in memory. ... > Dim xl As New Excel.Application ... >>> granting access rights to the resource to the ASP.NET request identity. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Very Slow reading excel data into an array (while opened in ne
    ... How can I read an excel file into memory without opening it? ... data array gets recycled each time it opens a new file so I don't have to ... Dim rowsMaster, colsMaster, lastCellMaster ...
    (microsoft.public.excel.programming)
  • Re: actxserver and related issues
    ... My problem is for Excel and i have seen posts on this group about it ... So memory is only used once, ... logical groups called interfaces. ... defined in an executable somewhere. ...
    (comp.soft-sys.matlab)
  • [PATCH 0/3] ia64: Migrate data off physical pages with correctable errors v3
    ... Migrate data off physical pages with corrected memory errors ... (per Christoph Lameter's request). ... Updated for recent page flag clean-up. ... handler to the page migration code. ...
    (Linux-Kernel)