Mercurial > hg > ooxml
comparison rect.xsl @ 16:2bbd067529b6
improve efficiency, detect blank rows, don't type empty cells
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Mon, 03 Apr 2017 19:22:03 +0100 |
parents | f78e8c55c06b |
children | 9b1b169dc8db |
comparison
equal
deleted
inserted
replaced
15:e767bef35bb9 | 16:2bbd067529b6 |
---|---|
27 <xsl:value-of select="codepoints-to-string(e:n2aa($n))"/> | 27 <xsl:value-of select="codepoints-to-string(e:n2aa($n))"/> |
28 </xsl:function> | 28 </xsl:function> |
29 | 29 |
30 <xsl:variable name="dim" select="//s:dimension/@ref"/> | 30 <xsl:variable name="dim" select="//s:dimension/@ref"/> |
31 <xsl:variable name="codeBase" select="string-to-codepoints('A')-1"/> | 31 <xsl:variable name="codeBase" select="string-to-codepoints('A')-1"/> |
32 | |
33 <xsl:template match="/"> | |
34 <xsl:apply-templates select="//s:sheetData"/> | |
35 </xsl:template> | |
32 | 36 |
33 <xsl:template match="s:sheetData"> | 37 <xsl:template match="s:sheetData"> |
34 <xsl:if test="s:row"> | 38 <xsl:if test="s:row"> |
35 <xsl:variable name="dims" select="analyze-string($dim,'([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)')"/> | 39 <xsl:variable name="dims" select="analyze-string($dim,'([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)')"/> |
36 <xsl:variable name="height" select="1+xs:integer($dims//xpf:group[@nr='4'])-xs:integer($dims//xpf:group[@nr='2'])"/> | 40 <xsl:variable name="height" select="1+xs:integer($dims//xpf:group[@nr='4'])-xs:integer($dims//xpf:group[@nr='2'])"/> |
39 <xsl:variable name="sheet" select="."/> | 43 <xsl:variable name="sheet" select="."/> |
40 <e:a> | 44 <e:a> |
41 <xsl:text> </xsl:text> | 45 <xsl:text> </xsl:text> |
42 <xsl:for-each select="(1 to $height)"><xsl:variable name="row" select="."/> | 46 <xsl:for-each select="(1 to $height)"><xsl:variable name="row" select="."/> |
43 <e:r r="{$row}"> | 47 <e:r r="{$row}"> |
44 <xsl:for-each select="(1 to $width)"> | 48 <xsl:variable select="$sheet/s:row[@r=$row]/s:c" name="cells"/> |
49 <xsl:if test="$cells/*"> | |
50 <xsl:for-each select="(1 to $width)"> | |
45 <xsl:variable name="col" select="."/> | 51 <xsl:variable name="col" select="."/> |
46 <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/> | 52 <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/> |
47 <xsl:variable name="c" select="$sheet/s:row/s:c[@r=$r]"/> | 53 <xsl:variable name="c" select="$cells[@r=$r]"/> |
48 <e:c c="{$col}"> | 54 <e:c c="{$col}"> |
49 <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if> | 55 <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if> |
50 <xsl:if test="$c"><xsl:value-of select="substring($c/@e:type,1,1)"/></xsl:if> | 56 <xsl:if test="$c/*"><xsl:value-of select="substring($c/@e:type,1,1)"/></xsl:if> |
51 </e:c> | 57 </e:c> |
52 </xsl:for-each> | 58 </xsl:for-each></xsl:if> |
53 </e:r> | 59 </e:r> |
54 <xsl:text> </xsl:text></xsl:for-each> | 60 <xsl:text> </xsl:text></xsl:for-each> |
55 </e:a> | 61 </e:a> |
56 </xsl:if> | 62 </xsl:if> |
57 </xsl:template> | 63 </xsl:template> |