<!---->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" version="1.0" exclude-result-prefixes="ss">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:template match="/">
<book>
<xsl:for-each select="//ss:Cell[./ss:Data]">
<xsl:element name="cell">
<xsl:attribute name="sheet">
<xsl:value-of select="../../../@ss:Name" />
</xsl:attribute>
<xsl:variable name="prevRows" select="../preceding-sibling::ss:Row" />
<xsl:attribute name="row">
<xsl:choose>
<xsl:when test="../@ss:Index">
<xsl:value-of select="../@ss:Index" />
</xsl:when>
<xsl:when test="count($prevRows) = 0">
<xsl:value-of select="1" />
</xsl:when>
<xsl:when test="count($prevRows[@ss:Index]) > 0">
<xsl:value-of select="($prevRows[@ss:Index][position()=1]/@ss:Index) + ((count($prevRows) + 1) - (count($prevRows[@ss:Index][position()=1]/preceding-sibling::ss:Row) + 1))" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count($prevRows) + 1" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:variable name="prevCells" select="preceding-sibling::ss:Cell" />
<xsl:attribute name="col">
<xsl:choose>
<xsl:when test="@ss:Index">
<xsl:value-of select="@ss:Index" />
</xsl:when>
<xsl:when test="count($prevCells) = 0">
<xsl:value-of select="1" />
</xsl:when>
<xsl:when test="count($prevCells[@ss:Index]) > 0">
<xsl:value-of select="($prevCells[@ss:Index][position()=1]/@ss:Index) + ((count($prevCells) + 1) - (count($prevCells[@ss:Index][position()=1]/preceding-sibling::ss:Cell) + 1)) + sum($prevCells/@ss:MergeAcross)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(preceding-sibling::ss:Cell) + 1 + sum(preceding-sibling::ss:Cell/@ss:MergeAcross)" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="ss:Data" />
</xsl:element>
</xsl:for-each>
</book>
</xsl:template>
</xsl:stylesheet>