GridView to Excel - but with header??

Discussion in 'ASP .Net' started by Daves, Sep 11, 2006.

  1. Daves

    Daves Guest

    hi,
    exporting GridView data to Excel is no problem but in the first data row I
    would like to put some descriptive information for the table. I cannot see
    any way to add this directly to the GridView so is there any way to add it
    to the final html table (guess I need to insert a <tr><td colspan=x ...)
    before sending it to Response?

    thx
    Daves, Sep 11, 2006
    #1
    1. Advertising

  2. You answered your own question.
    Prior to your Response.Write([Your Excel Data])

    just add standard HTML to the Response.

    string headerText = "Header Here";
    ie Response.Write ("<B>" + headerText + "</B>");

    or whatever you want.





    "Daves" wrote:

    > hi,
    > exporting GridView data to Excel is no problem but in the first data row I
    > would like to put some descriptive information for the table. I cannot see
    > any way to add this directly to the GridView so is there any way to add it
    > to the final html table (guess I need to insert a <tr><td colspan=x ...)
    > before sending it to Response?
    >
    > thx
    >
    >
    >
    =?Utf-8?B?T3Bh?=, Sep 11, 2006
    #2
    1. Advertising

  3. Daves

    Daves Guest

    well it's not possible since Excel will only accept and pars html that
    begins with a <table>

    So I need to dig into that html string and insert a tr with td colspan=...

    and before doing a complicated string function I'd like to know if there was
    an easier way?


    "Opa" <> wrote in message
    news:...
    > You answered your own question.
    > Prior to your Response.Write([Your Excel Data])
    >
    > just add standard HTML to the Response.
    >
    > string headerText = "Header Here";
    > ie Response.Write ("<B>" + headerText + "</B>");
    >
    > or whatever you want.
    >
    >
    >
    >
    >
    > "Daves" wrote:
    >
    >> hi,
    >> exporting GridView data to Excel is no problem but in the first data row
    >> I
    >> would like to put some descriptive information for the table. I cannot
    >> see
    >> any way to add this directly to the GridView so is there any way to add
    >> it
    >> to the final html table (guess I need to insert a <tr><td colspan=x ...)
    >> before sending it to Response?
    >>
    >> thx
    >>
    >>
    >>
    Daves, Sep 11, 2006
    #3
  4. Hi Daves,

    Perhaps, I am not sure how you are exporting to Excel. Are you using a
    DataGrid?
    If you are then what I described will work, because I am already doing the
    same thing.


    "Daves" wrote:

    > well it's not possible since Excel will only accept and pars html that
    > begins with a <table>
    >
    > So I need to dig into that html string and insert a tr with td colspan=...
    >
    > and before doing a complicated string function I'd like to know if there was
    > an easier way?
    >
    >
    > "Opa" <> wrote in message
    > news:...
    > > You answered your own question.
    > > Prior to your Response.Write([Your Excel Data])
    > >
    > > just add standard HTML to the Response.
    > >
    > > string headerText = "Header Here";
    > > ie Response.Write ("<B>" + headerText + "</B>");
    > >
    > > or whatever you want.
    > >
    > >
    > >
    > >
    > >
    > > "Daves" wrote:
    > >
    > >> hi,
    > >> exporting GridView data to Excel is no problem but in the first data row
    > >> I
    > >> would like to put some descriptive information for the table. I cannot
    > >> see
    > >> any way to add this directly to the GridView so is there any way to add
    > >> it
    > >> to the final html table (guess I need to insert a <tr><td colspan=x ...)
    > >> before sending it to Response?
    > >>
    > >> thx
    > >>
    > >>
    > >>

    >
    >
    >
    =?Utf-8?B?T3Bh?=, Sep 11, 2006
    #4
    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. Replies:
    1
    Views:
    1,779
    extentechjohn
    Nov 21, 2006
  2. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,947
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  3. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,486
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  4. Replies:
    0
    Views:
    410
  5. mlt
    Replies:
    2
    Views:
    820
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page