Skip to content

Preparing first output

foglcz edited this page Apr 22, 2013 · 15 revisions

Initial start

At first, you want to make sure that your installation is correct. Create your template.xsl file with following contents:

<?xml version='1.0'?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:include href="2012.engine.xsl" />

    <xsl:template match="/">
        <xsl:call-template name="generate_excel">
        </xsl:call-template>
    </xsl:template>
</xsl:stylesheet>

Then you should run this file with saxon processor. If you're not familiar, we have included a .bat file which contains the proper command:

"C:\Program Files\Saxonica\SaxonHE9.4N\bin\Transform.exe" -xsl:step1/template.xsl -warnings:recover -o:./step1/output -s:step1

There are several things going on, which we will cover in Under the hood chapter.

After processing the whole thing with saxon, you will have entire directory structure of your excel template created. Within there, you need to replace media/blank_picture.jpg with a correct file - saxon, by default, generates only blank files (and also screams about that.)

After replacing binaries with their proper counterparts, zip the contents and rename .zip to .xlsx . Then open the file and .. voila!

Next step

We need to go deeper

Now it's time for some showtime. Let's prepare your first and important include, which we use. Let's call it static.xsl . Into this file, we will create two variables:

<?xml version='1.0'?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:variable name="asset_theme">
    </xsl:variable>
    
    <xsl:variable name="asset_styles">
    </xsl:variable>
</xsl:stylesheet>

Now the important parts:

  1. Copy & paste the contents of xl/theme/theme1.xml into asset_theme variable, and
  2. Copy & paste the contents of xl/styles.xml into asset_styles variable, and
  3. Sanitize the excel's bullshit urls at the end of the styles:
            <extLst>
                <ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main">
                    <x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/>
                </ext>
                <ext uri="{9260A510-F301-46a8-8635-F512D64BE5F5}" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
                    <x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/>
                </ext>
            </extLst>

should turn into:

            <extLst>
                <ext xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main">
                    <xsl:attribute name="uri"><xsl:text>{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}</xsl:text></xsl:attribute>
                    <x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/>
                </ext>
                <ext xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
                    <xsl:attribute name="uri"><xsl:text>{9260A510-F301-46a8-8635-F512D64BE5F5}</xsl:text></xsl:attribute>
                    <x15:timelineStyles defaultTimelineStyle="TimeSlicerStyleLight1"/>
                </ext>
            </extLst>

Now let's go to the next chapter in order to populate some content.

Navigation

  1. Preparing excel files
  2. Preparing the first output
  3. Putting plain data into excel sheet
  4. Appending images
  5. Creating multiple worksheets
  6. Printer settings
  7. Macro-enabled workbooks
  8. Wrapping up

Clone this wiki locally