Export datalist to Excel - css format is lost!

S

staeri

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
 
G

Guest

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

Dracs

what did u do?


*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


-
Drac
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top