xsl-list
[Top] [All Lists]

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

2006-07-06 08:01:21
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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>