ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   html markup to specify data type of cells in Excel (https://www.excelbanter.com/excel-programming/303412-html-markup-specify-data-type-cells-excel.html)

Red Ogden

html markup to specify data type of cells in Excel
 
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

Jake Marx[_3_]

html markup to specify data type of cells in Excel
 
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]


Red Ogden wrote:
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



Red Ogden

html markup to specify data type of cells in Excel
 
Many thanks for that Jake.

Jake Marx[_3_]

html markup to specify data type of cells in Excel
 
Red Ogden wrote:
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]



All times are GMT +1. The time now is 05:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com