GridView to Excel - but with header??

  • Thread starter Thread starter Daves
  • Start date Start date
D

Daves

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
 
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.
 
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 said:
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 said:
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
 
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 said:
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 said:
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 said:
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
 
Back
Top