Mercurial > hg > ooxml
changeset 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 | e767bef35bb9 |
children | a874f2a81ed2 |
files | format.xsl html.xsl notes.txt rect.xsl |
diffstat | 4 files changed, 20 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/format.xsl Mon Apr 03 16:02:10 2017 +0100 +++ b/format.xsl Mon Apr 03 19:22:03 2017 +0100 @@ -16,7 +16,7 @@ <xsl:template match="s:worksheet"> <!-- Just here to bind the namespaces at the top --> - <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> + <worksheet xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" xmlns:xdr="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><xsl:apply-templates select="@*|node()"/></worksheet> </xsl:template> <xsl:template match="s:c[@t and @t!='n']">
--- a/html.xsl Mon Apr 03 16:02:10 2017 +0100 +++ b/html.xsl Mon Apr 03 19:22:03 2017 +0100 @@ -9,6 +9,7 @@ <head> <style> body {font-family: 'DejaVu Sans Mono' , monospace} + td {padding: 0} .e {color: red} .formula {font-style: italic} </style>
--- a/notes.txt Mon Apr 03 16:02:10 2017 +0100 +++ b/notes.txt Mon Apr 03 19:22:03 2017 +0100 @@ -38,3 +38,11 @@ --------- Decided to distinguish between type (num, date, str, err, ...) and class (cur, others to come?). If non-standard code, just record that. +---------- +Hmm, looking at real data (kenneth_lay__19506), I see _lots_ of cells +with (numerical) formats, but no content. Where do I throw those +away? Can throw away empty _rows_ in rect.xsl, but for _cells_ have +to wait for ascii.xsl or html.xsl. But only copy type in in rect if +there was content before. + +
--- a/rect.xsl Mon Apr 03 16:02:10 2017 +0100 +++ b/rect.xsl Mon Apr 03 19:22:03 2017 +0100 @@ -29,6 +29,10 @@ <xsl:variable name="dim" select="//s:dimension/@ref"/> <xsl:variable name="codeBase" select="string-to-codepoints('A')-1"/> + + <xsl:template match="/"> + <xsl:apply-templates select="//s:sheetData"/> + </xsl:template> <xsl:template match="s:sheetData"> <xsl:if test="s:row"> @@ -41,15 +45,17 @@ <xsl:text> </xsl:text> <xsl:for-each select="(1 to $height)"><xsl:variable name="row" select="."/> <e:r r="{$row}"> - <xsl:for-each select="(1 to $width)"> + <xsl:variable select="$sheet/s:row[@r=$row]/s:c" name="cells"/> + <xsl:if test="$cells/*"> + <xsl:for-each select="(1 to $width)"> <xsl:variable name="col" select="."/> <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/> - <xsl:variable name="c" select="$sheet/s:row/s:c[@r=$r]"/> + <xsl:variable name="c" select="$cells[@r=$r]"/> <e:c c="{$col}"> <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if> - <xsl:if test="$c"><xsl:value-of select="substring($c/@e:type,1,1)"/></xsl:if> + <xsl:if test="$c/*"><xsl:value-of select="substring($c/@e:type,1,1)"/></xsl:if> </e:c> - </xsl:for-each> + </xsl:for-each></xsl:if> </e:r> <xsl:text> </xsl:text></xsl:for-each> </e:a>