Setting Excel Column Width in ASP


J

j.t.w

Hi,

How do you set the column width of a <td>? I'm using
"Response.ContentType = "application/vnd.ms-excel" at the top of my
page to change the web page to an excel spreadsheet.

I've tried Response.Write("<td width=200>" & rst("Address") & "</td>")
but, it doesn't seem to change the column width.

Thanks if advance for any and all help.

j.t.w
 
Ad

Advertisements

B

Bwig Zomberi

j.t.w said:
Hi,

How do you set the column width of a<td>? I'm using
"Response.ContentType = "application/vnd.ms-excel" at the top of my
page to change the web page to an excel spreadsheet.

I've tried Response.Write("<td width=200>"& rst("Address")& "</td>")
but, it doesn't seem to change the column width.

Thanks if advance for any and all help.

j.t.w


Haven't checked this but it may work:

<td style="width: 200px; ">
 
D

Dan

j.t.w said:
Hi,

How do you set the column width of a <td>? I'm using
"Response.ContentType = "application/vnd.ms-excel" at the top of my
page to change the web page to an excel spreadsheet.

I've tried Response.Write("<td width=200>" & rst("Address") & "</td>")
but, it doesn't seem to change the column width.

Thanks if advance for any and all help.

j.t.w

You're not actually creating an Excel spreadsheet - you're using a trick of
the MIME type to get the browser to load the resulting page in Excel, but
the actual output is HTML and it's relying on the Excel HTML parser to
convert it to an Excel spreadsheet format. So you need to figure out what
Excel will parse, and what it will ignore, when processing HTML, and use
that to figure out what attributes can be used. It might well be as simple
as simply needing to enclose the width in quotes, eg.

Response.Write("<td width=""200"">" & rst("Address") & "</td>")

(when you want to include a double quote within a string, simply double it
up so it's not treated as a string terminator).
 
B

Bob Barrows

j.t.w said:
Hi,

How do you set the column width of a <td>? I'm using
"Response.ContentType = "application/vnd.ms-excel" at the top of my
page to change the web page to an excel spreadsheet.

I've tried Response.Write("<td width=200>" & rst("Address") & "</td>")
but, it doesn't seem to change the column width.

Thanks if advance for any and all help.

j.t.w

Create a spreadsheet in Excel whose columns are set to the widths you want
and then save it to html. View the source to see the markup that Excel needs
to properly format the column widths.
 
Ad

Advertisements

J

j.t.w

Thank you all for your help and suggestions. I finally got it working
properly.

My problem was there were more than one Response.Write("<table>") in
my code. Once I removed all but the outermost <table>, the width
property started working.

Thanks again.
j.t.w
 

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

Similar Threads


Top