Search

A new XSLT utility, “Export to Microsoft Excel 2003 XML” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

Nice one kanduvisia. Most useful.

This is a great extension! I have used it successfully a couple times. I ran into an issue in a recent project, however, where the people receiving the excel file complained that the number data was giving the "number stored as text" error.

After poking about a bit in the utility, I moved the

`<Data ss:Type="String">`

Element from the "excelOutputData" template, moving it down into the "excelGetData" template, so that template now looks like this:

`<xsl:template name="excelGetData" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
    <xsl:param name="field" />
    <xsl:param name="withItem" />
    <Data>
        <xsl:choose>
            <xsl:when test="number($field)">
                <xsl:attribute name="ss:Type">Number</xsl:attribute>
            </xsl:when>
            <xsl:otherwise>
                <xsl:attribute name="ss:Type">String</xsl:attribute>
            </xsl:otherwise>
        </xsl:choose>
    <!-- Show the value: -->
    <xsl:choose>
        <!-- Check if it has sub-items: -->
        <xsl:when test="count($field/*) = 0">
            <!-- Show default value: -->
            <xsl:value-of select="$field" />
        </xsl:when>
        <xsl:otherwise>
            <!-- Field doesn't have a value, treat as an item: -->                      
            <xsl:choose>
                <xsl:when test="$withItem = 'implode'">
                    <xsl:for-each select="$field/*">
                        <xsl:value-of select="." />
                        <xsl:if test="position() != last()">, </xsl:if>
                    </xsl:for-each>                                             
                </xsl:when>
                <xsl:when test="$withItem = 'last'">
                    <xsl:value-of select="$field/*[last()]" />
                </xsl:when>
                <xsl:when test="$withItem = 'first'">
                    <xsl:value-of select="$field/*[1]" />
                </xsl:when>                                     
            </xsl:choose>
        </xsl:otherwise>
    </xsl:choose>
    </Data>
</xsl:template>`

It's not a perfect solution (doesn't deal with what should be number-formatted empty cells), but it did the trick satisfactorially for my client.

If anyone can think of a more efficient or better way to do it, let me know! Thanks again for a great utility!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details