Skip to content

Creating multiple worksheets

foglcz edited this page Apr 22, 2013 · 6 revisions

On previous chapter we mentioned having multiple worksheets. So, if the engine gets only one parameter - the sheetContents, how the heck do we generate more?

It's actually simpler than it looks. Just steal contents of all your sheetX.xml files, and put them all into one place!

Here's a snippet how to generate three sheets:

<xsl:with-param name="sheetContents">
    <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
        <!-- first sheet -->
    </worksheet>
    <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
        <!-- second sheet -->
    </worksheet>
    <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac" mc:Ignorable="x14ac">
        <!-- third sheet -->
    </worksheet>
</xsl:with-param>

But - when you're working with multiple sheets, you need to provide their names. That is done via sheetNames parameter:

<xsl:with-param name="sheetNames">
    <name>First sheet</name>
    <name>Second sheet</name>
    <name>Third sheet</name>
</xsl:with-param>

And.. That's all there is to it.

I actually wish this section was longer. But there's nothing more to be said.

If not, please create an issue!

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. Under the hood
  9. Engine parameters documentation
  10. Best practice for writing Excel XML
  11. Authors, license, contributing