button to export to excel

Discussion in 'ASP .Net Web Controls' started by DC Gringo, Jan 31, 2005.

  1. DC Gringo

    DC Gringo Guest

    I have a simple button that should open another window and export a datagrid
    to an Excel file. I'm getting: "Name 'window' is not declared."

    What do I need to declare or import?


    <INPUT ID="Button5" ONCLICK="Button5_Click" NAME="Button5" TYPE="button"
    VALUE="Export to Excel">

    Sub Button5_Click()
    Dim sHTML
    sHTML = window.Form1.children("dgCommunities").outerhtml()
    Dim oXL, oBook
    oXL = CreateObject("Excel.Application")
    oBook = oXL.Workbooks.Add
    oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
    oBook.HTMLProject.RefreshDocument()
    oXL.Visible = True
    oXL.UserControl = True
    End Sub


    --
    _____
    DC G
     
    DC Gringo, Jan 31, 2005
    #1
    1. Advertising

  2. The error message appears to be accurate.
    I don't see any code where you actually create a new window.

    Here's some examples for you:
    http://SteveOrr.net/Articles/ClientSideSuite.aspx
    http://SteveOrr.net/articles/ExcelExport.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    "DC Gringo" <> wrote in message
    news:%23YfN$s%...
    >I have a simple button that should open another window and export a
    >datagrid
    > to an Excel file. I'm getting: "Name 'window' is not declared."
    >
    > What do I need to declare or import?
    >
    >
    > <INPUT ID="Button5" ONCLICK="Button5_Click" NAME="Button5" TYPE="button"
    > VALUE="Export to Excel">
    >
    > Sub Button5_Click()
    > Dim sHTML
    > sHTML = window.Form1.children("dgCommunities").outerhtml()
    > Dim oXL, oBook
    > oXL = CreateObject("Excel.Application")
    > oBook = oXL.Workbooks.Add
    > oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
    > oBook.HTMLProject.RefreshDocument()
    > oXL.Visible = True
    > oXL.UserControl = True
    > End Sub
    >
    >
    > --
    > _____
    > DC G
    >
    >
     
    Steve C. Orr [MVP, MCSD], Feb 1, 2005
    #2
    1. Advertising

  3. I think you're taking the wrong approach if you're using ASP.NET with Excel.

    You might want to look at one of these articles:

    http://www.dotnetjohn.com/articles/articleid78.aspx

    http://www.c-sharpcorner.com/Code/2003/Sept/ExportASPNetDataGridToExcel.asp

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

    "DC Gringo" <> wrote in message
    news:%23YfN$s%...
    >I have a simple button that should open another window and export a
    >datagrid
    > to an Excel file. I'm getting: "Name 'window' is not declared."
    >
    > What do I need to declare or import?
    >
    >
    > <INPUT ID="Button5" ONCLICK="Button5_Click" NAME="Button5" TYPE="button"
    > VALUE="Export to Excel">
    >
    > Sub Button5_Click()
    > Dim sHTML
    > sHTML = window.Form1.children("dgCommunities").outerhtml()
    > Dim oXL, oBook
    > oXL = CreateObject("Excel.Application")
    > oBook = oXL.Workbooks.Add
    > oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
    > oBook.HTMLProject.RefreshDocument()
    > oXL.Visible = True
    > oXL.UserControl = True
    > End Sub
    >
    >
    > --
    > _____
    > DC G
    >
    >
     
    Ken Cox [Microsoft MVP], Feb 1, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2aWQgVmFsbGU=?=

    Invalid export DLL or export format

    =?Utf-8?B?RGF2aWQgVmFsbGU=?=, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,640
    =?Utf-8?B?RGF2aWQgVmFsbGU=?=
    Oct 29, 2003
  2. DC Gringo

    button to export to excel

    DC Gringo, Jan 31, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    4,371
    DC Gringo
    Feb 14, 2005
  3. =?Utf-8?B?U3JpZGhhcg==?=

    using Microsoft Excel image for Export to Excel button

    =?Utf-8?B?U3JpZGhhcg==?=, Dec 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    3,133
    =?Utf-8?B?U3JpZGhhcg==?=
    Dec 9, 2005
  4. =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?=

    Export to Excel (Default File Type - Excel)

    =?Utf-8?B?SGVtYW50IFNpcGFoaW1hbGFuaQ==?=, Apr 24, 2006, in forum: ASP .Net
    Replies:
    15
    Views:
    17,579
    syed hassan
    May 21, 2009
  5. Grey
    Replies:
    4
    Views:
    2,037
    Mark Rae [MVP]
    Oct 17, 2007
Loading...

Share This Page