exporting webpage to excel formatting problem

J

Jeremy

Hi, I have a webpage that is taking input from a form and using it as
criteria to select data out of an sql database. The page displays an
html table with the results. The user can then click a button "excel"
to open or save the file as an excel document. This works, and
everything in the excel document is formatted fine except for the
first column which in this case is "Part Number". The problem is that
this part number: 883100105100 is displayed like this: 8.831E+11 in
excel. I am not sure how to format the excel cells using the asp/html
so that it doesn't try to throw everything into scientific notation.
I have thought that maybe if I gave excel a string value instead of a
number value then it would fix the problem but I am pretty new to asp
and am not sure how to do this. Below is the block that throws
everything into excel in the first place. Any help would be great,
thank you!

<%
'Change HTML header to specify Excel's MIME content type

Response.Buffer = TRUE
Response.ContentType = "application/vnd.ms-excel"
%>
 
R

Ray at

Precede the values with a ' character, like, instead of 883100105100, make
it so it's '883100105100.

Ray at home
 
T

Tim Williams

If you have XL2k or greater, format a few cells on a worksheet as text,
select them, and save the selection as HTML.

This will help you construct a style sheet to format the cells

eg:

<style>
<!--table
..xlText {mso-number-format:"\@";}
-->
</style>


Then use

<td class="xlText">883100105100</td>


Tim.
 
J

Jeremy

Hi Ray, thanks for the suggestion, but it didn't work. . it no longer
displays the number in scientific notation but now it displays it like
this: '883100105100 . . .it doesn't hide the apostrophe. Though the
strange thing is, once I'm in excel if I delete the apostrophe and
type it in myself, then it hides it. I guess excel doesn't like
apostrophe's from html :)

Thanks Again,

Jeremy
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top