Home All Groups Group Topic Archive Search About

Open Excel file with ASP.Net

Author
10 Apr 2006 9:32 AM
Raggie
Gentlemen,


first of all I have a general question... is it possible to open an
excel file directly through the ASP.NET page without to install Excel
on server?


I tried something on my localhost...


this following code creates an Excel.exe instance in my TaskMgr but I
am not able to make it visible...
I debugged several times through the code. I tested ex.visible
immediately after I set it true... it was still false!!!


Private Sub btnExcel_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnExcel.Click
        Dim path As String = AppSettings("Pivotpath") ' "C:\pivot\
        path = path & "63.xls" 'dummy
        Dim ex As Excel.Application
        Dim wb As Excel.Workbook
        ' Dim ws As Excel.Worksheet
        ex = CreateObject("Excel.Application")
        wb = ex.Workbooks.Open(path)
        ex.Visible = True
        'wb = ex.Workbooks.Open(path)
        'ws = ex.Worksheets.Item(1)


        'ws.Activate()
        'ex.Windows(1).Activate()
        'ex.Sheets(1).visible = True


        'ex.Application.Visible = True


        '        ex.Visible = Not ex.Visible


        '        ws = wb.Worksheets(1)
        excontrol = True


        ex.EnableEvents = False


        Me.lblExControl.Text = "true"
        Me.lblExControl.Visible = True
        ' Response.WriteFile(path)


    End Sub


thx & regards


Raggie

Author
10 Apr 2006 10:30 AM
Ken Tucker [MVP]
Raggie,

        You should not automate excel from a web application.  To display it
in the webpage navigate to the xls file.

Here is a link on how to create a spreadsheet in a web application using xml
transformations.

http://support.microsoft.com/default.aspx?scid=kb;en-us;319180

Ken
----------------
Show quoteHide quote
"Raggie" <rasi***@googlemail.com> wrote in message
news:1144661579.066254.158020@e56g2000cwe.googlegroups.com...
> Gentlemen,
>
>
> first of all I have a general question... is it possible to open an
> excel file directly through the ASP.NET page without to install Excel
> on server?
>
>
> I tried something on my localhost...
>
>
> this following code creates an Excel.exe instance in my TaskMgr but I
> am not able to make it visible...
> I debugged several times through the code. I tested ex.visible
> immediately after I set it true... it was still false!!!
>
>
> Private Sub btnExcel_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles btnExcel.Click
>        Dim path As String = AppSettings("Pivotpath") ' "C:\pivot\
>        path = path & "63.xls" 'dummy
>        Dim ex As Excel.Application
>        Dim wb As Excel.Workbook
>        ' Dim ws As Excel.Worksheet
>        ex = CreateObject("Excel.Application")
>        wb = ex.Workbooks.Open(path)
>        ex.Visible = True
>        'wb = ex.Workbooks.Open(path)
>        'ws = ex.Worksheets.Item(1)
>
>
>        'ws.Activate()
>        'ex.Windows(1).Activate()
>        'ex.Sheets(1).visible = True
>
>
>        'ex.Application.Visible = True
>
>
>        '        ex.Visible = Not ex.Visible
>
>
>        '        ws = wb.Worksheets(1)
>        excontrol = True
>
>
>        ex.EnableEvents = False
>
>
>        Me.lblExControl.Text = "true"
>        Me.lblExControl.Visible = True
>        ' Response.WriteFile(path)
>
>
>    End Sub
>
>
> thx & regards
>
>
> Raggie
>