Page tree
Skip to end of metadata
Go to start of metadata

This script can be used in ScriptRunner to run export. Use ScriptRunner Jobs to add scheduling.


Export to excel
import com.atlassian.jira.component.ComponentAccessor
String fileName = 'filename.xls'
String userName = 'admin'
Long structureId = 1L
Long viewId = 2L
String viewSpec = null
String expandState = null
String clientFilter = null
def plugin = ComponentAccessor.pluginAccessor.getPlugin('com.almworks.jira.structure')
def helper = plugin.getModuleDescriptor('helper').module
def ExcelExporter = plugin.classLoader.loadClass('com.almworks.jira.structure.export.excel.ExcelExporter')
def exporter = helper.instantiate(ExcelExporter)
def ForestSpec = plugin.classLoader.loadClass('com.almworks.jira.structure.api.forest.ForestSpec')
def spec = ForestSpec.structure(structureId, helper.userManager.getUser(userName))
exporter.configure(viewId, viewSpec, spec, expandState, clientFilter)
exporter.prepareExport()
exporter.createWorkbook({null})
def stream = new FileOutputStream(fileName)
try {
    exporter.writeWorkbookTo(stream)
} finally {
    stream.close()
    return new File(fileName).toPath().toAbsolutePath()
}




  • No labels