By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,494 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,494 IT Pros & Developers. It's quick & easy.

Export datalist to Excel - css format is lost!

P: n/a
I'm trying to export a datalist to Excel with this code:

Response.Clear()
Response.Buffer = True
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False
Dim sw As StringWriter = New StringWriter()
Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
DataList1.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()

Unfortunately all the format set from css is lost. Is there a way to
get around this?

Regards,

S

Mar 14 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I'm working on a classic ASP page that will invoke the Excel plugin when
using IE. Here's how I start it.
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

After that I do a bunch of code to get data from a database.Then I just
construct an HTML table and use a style block for formating as in

<style>
table,td{border-style:solid;border-color:#C0C0C0;border-width:thin}
.title{font-weight:bold}
.label{font-weight:bold;padding-left:1em;vertical-align:middle}
.colhead{font-weight:bold;text-align:center;vertical-align:middle}
.participants{vertical-align:middle;padding-left:1em;height:24}
.badge{vertical-align:middle;text-align:right}
.total{font-weight:bold;vertical-align:middle;padding-left:6em;height:24}
</style>

Here's a snippet of the html coding

<tr>
<td class="label">Course Name:</td>
<td colspan=2 class="title"><%=strClassName%></td></tr>
<tr>
<td class="label">Dates:</td>
<td colspan=2>
<%=datStartDate%> to <%=datEndDate%><br></td></tr>

this is all working fine.

my problem is how to force a page break.

--
no place like 127.0.0.1
"st****@gmail.com" wrote:
I'm trying to export a datalist to Excel with this code:

Response.Clear()
Response.Buffer = True
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False
Dim sw As StringWriter = New StringWriter()
Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
DataList1.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()

Unfortunately all the format set from css is lost. Is there a way to
get around this?

Regards,

S

Apr 5 '06 #2

P: n/a

what did u do?
st****@gmail.com wrote:
*I'm trying to export a datalist to Excel with this code:

Response.Clear()
Response.Buffer = True
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False
Dim sw As StringWriter = New StringWriter()
Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
DataList1.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()

Unfortunately all the format set from css is lost. Is there a way to
get around this?

Regards,

S *


--
Dracs
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

May 24 '06 #3

P: n/a
Dracs
see Steve's article http://steveorr.net/articles/ExcelExport.aspx
Patrick

"Dracs" <Dr**********@mail.codecomments.com> wrote in message
news:Dr**********@mail.codecomments.com...

what did u do?
st****@gmail.com wrote:
*I'm trying to export a datalist to Excel with this code:

Response.Clear()
Response.Buffer = True
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Me.EnableViewState = False
Dim sw As StringWriter = New StringWriter()
Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
DataList1.RenderControl(hw)
Response.Write(sw.ToString())
Response.End()

Unfortunately all the format set from css is lost. Is there a way to
get around this?

Regards,

S *


--
Dracs
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

May 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.