GridView to Excel - but with header??

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
 
G

Guest

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.
 
D

Daves

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
 
G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top