Export a Jira Project into XLS/XSLX/CSV

When exporting a CSV or a file for Excel, special and simple templates must be used in order for the export to produce usable results.

The CSV template must generate a CSV header row as well as single rows for each "dataset". A simple template is included in the app.

The Excel template must only generate a HTML table with clean table rows and table cells. Table header rows will be formatted according to a hard coded style. All extra formatting will be ignored.

The CSV and Excel templates may always be exported in HTML format to verify proper formatting if required.

Exporting a Jira Project

Examples:

Example of a CSV Template

The variable $firstRun is only true during the first time this template is rendered. This is useful when exporting all Jira projects into one large CSV file, as this template will be called for each Jira project to be exported separately. The resulting data will be merged into a large CSV file.

jira-project-to-screen-to-field-csv.vm
#set ( $firstRun = ${helper.getGlobalContext().getOrDefault("firstRun", false)} )
#if ( $firstRun )
"Project","IssueTypeScreenScheme","IssueType","Screen","Tab","Field","FieldID","FieldType"
#end
#set ( $issueTypeScreenScheme = ${helper.getIssueTypeScreenScheme()} )
#set ( $screenSchemes = ${issueTypeScreenScheme.getEntities()} )
#foreach ( $screenScheme in $screenSchemes )
#set ( $issueType = $!{screenScheme.getIssueType().getName()} )
#set( $extraContext = {} )
#if ( $issueType )
#set( $extraContext.issueTypeName = $issueType )
#else
#set( $extraContext.issueTypeName = "Default (All Unassigned Issue Types)" )
#end
#set( $extraContext.screenSchemeName = $!{screenScheme.getFieldScreenScheme().getName()} )
#set( $extraContext.fieldScrenSchemeItems = $!{screenScheme.getFieldScreenScheme().getFieldScreenSchemeItems()} )
#foreach ( $fieldScrenSchemeItem in $extraContext.fieldScrenSchemeItems )
#set ( $text = ${fieldScrenSchemeItem.getIssueOperationName()} )
#set ( $screen = $!{fieldScrenSchemeItem.getFieldScreen()} )
#set ( $tabs = $screen.tabs )
#foreach ( $tab in $tabs )
#set ( $items = ${tab.getFieldScreenLayoutItems()} )
#foreach ( $item in $items )
#set ( $customfield = false )
#set ( $field = ${item.getOrderableField()} )
#set ( $customfield = ${helper.getCustomFieldObject($!field.id)} )
#if ( $customfield )
"${project.key}","$!{issueTypeScreenScheme.name}","${extraContext.issueTypeName}","$!{i18n.getText($text)} $!{screen.name}","$!{tab.name}","$field.name","$field.id","$!{customfield.getCustomFieldType().getName()}"
#else
"${project.key}","$!{issueTypeScreenScheme.name}","${extraContext.issueTypeName}","$!{i18n.getText($text)} $!{screen.name}","$!{tab.name}","$field.name","$field.id",""
#end
#end
#end
#end
#end

Example of a XLS/XLSX Template

This template generates a simple table which is then converted into a Excel sheet in a workbook. When exporting all Jira projects at once each table will result in a new sheet in the same workbook and the sheet will be labeled after the projects key.

jira-project-to-screen-to-field-xls.vm
<table>
<tr>
<th>Project</th><th>IssueTypeScreenScheme</th><th>IssueType</th><th>Screen</th><th>Tab</th><th>Field</th><th>FieldID</th><th>FieldType</th>
</tr>
#set ( $issueTypeScreenScheme = ${helper.getIssueTypeScreenScheme()} )
#set ( $screenSchemes = ${issueTypeScreenScheme.getEntities()} )
#foreach ( $screenScheme in $screenSchemes )
#set ( $issueType = $!{screenScheme.getIssueType().getName()} )
#set( $extraContext = {} )
#if ( $issueType )
#set( $extraContext.issueTypeName = $issueType )
#else
#set( $extraContext.issueTypeName = "Default (All Unassigned Issue Types)" )
#end
#set( $extraContext.screenSchemeName = $!{screenScheme.getFieldScreenScheme().getName()} )
#set( $extraContext.fieldScrenSchemeItems = $!{screenScheme.getFieldScreenScheme().getFieldScreenSchemeItems()} )
#foreach ( $fieldScrenSchemeItem in $extraContext.fieldScrenSchemeItems )
#set ( $text = ${fieldScrenSchemeItem.getIssueOperationName()} )
#set ( $screen = $!{fieldScrenSchemeItem.getFieldScreen()} )
#set ( $tabs = $screen.tabs )
#foreach ( $tab in $tabs )
#set ( $items = ${tab.getFieldScreenLayoutItems()} )
#foreach ( $item in $items )
#set ( $customfield = false )
#set ( $field = ${item.getOrderableField()} )
#set ( $customfield = ${helper.getCustomFieldObject($!field.id)} )
<tr>
#if ( $customfield )
<td>${project.key}</td><td>$!{issueTypeScreenScheme.name}</td><td>${extraContext.issueTypeName}</td><td>$!{i18n.getText($text)} $!{screen.name}</td><td>$!{tab.name}</td><td>$field.name</td><td>$field.id</td><td>$!{customfield.getCustomFieldType().getName()}</td>
#else
<td>${project.key}</td><td>$!{issueTypeScreenScheme.name}</td><td>${extraContext.issueTypeName}</td><td>$!{i18n.getText($text)} $!{screen.name}</td><td>$!{tab.name}</td><td>$field.name</td><td>$field.id</td><td></td>
#end
</tr>
#end
#end
#end
#end
</table>