Mercurial > hg > ooxml
diff format.xsl @ 6:d6dae580f6a0
preliminary attempt to detect currency formatting
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Sun, 02 Apr 2017 16:49:48 +0800 |
parents | 106bf970a867 |
children | fd8678fb7b4d |
line wrap: on
line diff
--- a/format.xsl Sat Apr 01 23:50:20 2017 +0800 +++ b/format.xsl Sun Apr 02 16:49:48 2017 +0800 @@ -7,6 +7,13 @@ <xsl:variable name="styles" select="document(concat($xldir,'/styles.xml'))/*"/> <xsl:variable name="xfs" select="$styles//s:cellXfs/s:xf"/> <xsl:variable name="nfs" select="$styles//s:numFmts/s:numFmt"/> + + <xsl:function name="e:currencyFormatP" as="xs:boolean"> + <xsl:param name="format"/> + <!-- Really need a unicode block check --> + <xsl:value-of select="matches($format,concat('^["',"'",'][£$¢-¥]'))"/> + </xsl:function> + <xsl:template match="s:worksheet"> <worksheet xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"><xsl:apply-templates select="@*|node()"/></worksheet> </xsl:template> @@ -19,14 +26,22 @@ <c> <xsl:choose> <xsl:when test="$biClass"> - <xsl:attribute namespace="http://markup.co.uk/excel" name="class"> + <xsl:attribute namespace="http://markup.co.uk/excel" name="fClass"> <xsl:value-of select="$biClass"/> </xsl:attribute> </xsl:when> <xsl:when test="$nfs[@numFmtId=$nfi]"> - <xsl:attribute namespace="http://markup.co.uk/excel" name="code"> - <xsl:value-of select="$nfs[@numFmtId=$nfi]/@formatCode"/> + <xsl:variable name="code" select="$nfs[@numFmtId=$nfi]/@formatCode"/> + <xsl:choose> + <xsl:when test="e:currencyFormatP($code)"> + <xsl:attribute namespace="http://markup.co.uk/excel" name="fClass">cur</xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute namespace="http://markup.co.uk/excel" name="code"> + <xsl:value-of select="$code"/> </xsl:attribute> + </xsl:otherwise> + </xsl:choose> </xsl:when> </xsl:choose> <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>