[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Number formating (format-number) and string to number function problem.


Subject: [xsl] Number formating (format-number) and string to number function problem.
From: "Karen Yang" <kyang94@xxxxxxxxx>
Date: Thu, 6 Jul 2006 11:01:01 -0400

Hello,

I'm converting the XML to Excel using XSLT 1.0, and now I'm having a
problem with the number result in Excel.

For example, I have a number stored as 1234.5678, and I'd like to see
1,234.57 as the final format, so I used format-number() function, but
that function would convert the result to string instead of a number,
so when I use
<Cell><Data ss:Type="Number"><xsl:value-of select="format-number(.,
'###,.00')"/></Data></Cell>

The generated Excel would have problem opening, but if I change to:

<Cell><Data ss:Type="String"><xsl:value-of select="format-number(.,
'###,.00')"/></Data></Cell>

The file could be opened, but all the numbers are stored as string, so
there would be a warning sign (little triangle on the left upper
corner) showed up in every cell that is number value but string type.

I also tried to use "number()" function as shown below, but it's very
strange that the result would be "NaN" for most values.

<Cell><Data ss:Type="String"><xsl:value-of
select="number(format-number(., '###,.00'))"/></Data></Cell>

So can sb. let me know what I should do in this situation? My main
goal is to have the number formated as ###..00.

And if I don't format the numbers,
<Cell><Data ss:Type="Number"><xsl:value-of select="."/></Data></Cell>

It would work just fine....

Since I'd like to wrap my current project up by today, I'd appreciate
any of your outputs.

Thanks in advance for your help,

Karen.


Current Thread
Keywords