html markup to specify data type of cells in Excel

R

Red Ogden

Please can anyone tell me how to specify in html that the data-type of
a column is text rather than general.

I am generating an html table using XSL to be opened in Excel but one
column loses it's leading zeros and I therefore want to specify the
above in the output html.

Any help will be gratefully received.

Redge
 
J

Jake Marx

Hi Redge,

If you can use a CSS style attribute, this should work for you (shown here
applied to a <td> element):

<td style="mso-number-format:\@">00001</td>

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
J

Jake Marx

Red said:
Many thanks for that Jake.

No problem, Redge.

Just to help you solve problems like this in the future, here are the steps
I took to determine the style needed in this case:

1) formatted column A as text
2) entered number 00012 in cell A1
3) entered number 00012 in cell B1 (changed to 12 when entered)
4) opened the Microsoft Script Editor (Alt+Shift+F11)
5) located the <column> that contained 00012
6) saw that the class assigned to that <column> is named "xl24"
7) located ".xl24" in the <style> block in the page header
8) noticed the "mso-number-format" style and copied it
9) created a new HTML document with a simple table
10) in one <td>, set the style attribute to text copied from step 8
11) in that <td>, use the value 00012
12) in another <td>, use the value 00012
13) save the HTML document
14) open the document with Excel
15) notice that the first cell comes through with leading 0's
and the second doesn't

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Top