You are here: Best Practices > FO to XSL (Excel)

FO to XSL (Excel)


This article describes how to convert from XSL–FO to an Excel Spreadsheet.


Converting XSL–FO to an Excel Spreadsheet

  1. Remove Excel Gridlines from the output by adding the following to the worksheet options:


  2. Set the default Zoom level of the spreadsheet by adding the following to the worksheet options (in this example, 75%):


  3. Preserve Rich Text Attribute formatting on the Excel output. The value of the Rich Text attribute stored in the Document XML will be something like:

    <p><em>Quo usque tandem abutere, Catalina, patienta nostra?</em><p>


    <p><strong><u>Quam diu etiam furor iste tuus nos eludet?</u></strong></p>


    <p><strong><u><em>Quem ad fidenm sese effrenata iactabit audacia?</em></u></strong></p>

The attribute's data is not enclosed in CDATA when being used for Printer Friendly/History XSL documents. (However, this is not true for Integration XSLs). Thus, you can import the rich text attribute and treat it like a node set, and use XPath functions and expressions to traverse its contents. For example:

<xsl:value-of select="$main_doc/richTextAttribute_quote/p[1]/em"/> => Quo usque tandem abutere, Catalina, patienta nostra?

There are three templates for parsing Bold, Italic, and Underlined text from a Rich Text Attribute:

The internal call to <xsl:apply-templates> ensures that templates are called recursively on the input to each template, until no more templates are found matching any nested nodes (for example, plain text).

The XML namespace declaration is required within the scope of where the Excel XML tags (<B>, <U>, <I>) are being used. In this case, they are being used inside templates. If they are being hard-coded into a <Data> attribute, the XML namespace must be declared there as well.

For example:

<Data ss:Style="aStyle" xmlns="">


<B>This is bold text</B>

<B><U>This is bold and underlined text</U></B>



The above templates can then be called using the <xsl:apply-templates> element:



<xsl:apply-templates select="$main_doc/richTextAttribute_quote/*"/>





Related Topics Link IconSee Also