DataGrid Export to Excel

Discussion in 'ASP .Net Datagrid Control' started by Etlon Wang, Mar 8, 2005.

  1. Etlon Wang

    Etlon Wang Guest

    Something very weird.

    >-----Original Message-----
    >Hi all,
    >
    >This site and all its users have been a huge help, and

    now I need a little help.
    >
    >I've got a page with a DataGrid on it that is formatted

    and beautiful the way I like it, and I'm trying to export
    the DataGrid to excel, but not having any luck. On this
    particular page I'm not using a code behind page, so I've
    the put the export routine in a Sub that's called by a
    button to export the data. I'm not getting any errors, but
    when you click the button the entire page goes blank.
    >
    >Here's the Sub:
    >
    >Sub DataGridToExcel(s as object, e as eventargs)
    > Response.Clear()
    > Response.Charset = ""
    > Response.ContentType = "application/vnd.ms-excel"
    > Dim stringWrite as New System.IO.StringWriter()
    > Dim htmlWrite as New System.Web.UI.HtmlTextWriter

    (stringWrite)
    > dim dg As New DataGrid()
    > dg = dgrdApproval
    > dg.Gridlines = Gridlines.None
    > dg.HeaderStyle.Font.Bold = True
    > dg.DataBind()
    > dg.RenderControl(htmlWrite)
    > Response.Write(stringWrite.ToString)
    > Response.End()
    >End Sub
    >
    >Any ideas why this doesn't open a "Save As" dialog?
    >
    >--------------------------------
    >From: Mike Lord
    >
    >-----------------------
    >Posted by a user from .NET 247 (http://www.dotnet247.com/)
    >
    ><Id>ogV1/WSo1Uiy8P4UdOn0vQ==</Id>
    >.
    >
    Etlon Wang, Mar 8, 2005
    #1
    1. Advertising

  2. The Web interface acts up sometimes and inserts question marks instead of
    the real text.


    "Etlon Wang" <> wrote in message
    news:5a7701c523e1$239f1890$...
    > Something very weird.
    Ken Cox [Microsoft MVP], Mar 9, 2005
    #2
    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. Cowboy \(Gregory A. Beamer\)

    Export datagrid(with allowsorting) to Excel

    Cowboy \(Gregory A. Beamer\), Jun 25, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    508
  2. =?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,075
    =?Utf-8?B?U3JpZGhhcg==?=
    Dec 9, 2005
  3. =?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,461
    syed hassan
    May 21, 2009
  4. Grey
    Replies:
    4
    Views:
    1,935
    Mark Rae [MVP]
    Oct 17, 2007
  5. Paul D. Fox

    Display a Datagrid & Export a Datagrid to Excel

    Paul D. Fox, Jul 21, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    206
    Elton Wang
    Jul 21, 2005
Loading...

Share This Page