#1 2016-06-17 12:56:42

cchris26
Member
From: Munich
Registered: 2016-05-09

Generating Excel from Script Report

Hi,

I try to build a simple Excel document using Apache POI library in a Groovy script which is executed by a Script Report. I try to use the object net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledXlsxReport for which I have unfortunately no API. My output is an ObjectOutputStream or a FileOutputStream but I cannot provide them to the CompiledXlsxReport class.

Do you have a simple functioning example in this respect?

Many thanks in advance.
Cristian

Offline

#2 2016-06-17 15:49:04

karolina
Member
Registered: 2014-08-09

Re: Generating Excel from Script Report

Hi Christian,

ReportServer CE sources and apidoc can be found here
In most cases it should be sufficient as a help in scripting.

Below is a fragment of a script that I use:

/* create POI Workbook */
def excel2008 = true
def wb = null

if(! excel2008) {
    wb = new HSSFWorkbook();
} else {
    wb = new XSSFWorkbook();
}

// your code here

// when you are ready with the workbook, then:  

/* generate bos */
def bos = new ByteArrayOutputStream()
wb.write(bos)

/* get bytes and close stream */
def result = new CompiledXlsxReport(bos.toByteArray())
bos.close()

return result

Hope it helps.
Karolina

Offline

#3 2016-06-20 09:05:19

cchris26
Member
From: Munich
Registered: 2016-05-09

Re: Generating Excel from Script Report

Hi Karolina,

Many thanks for the info and for your script. This is exactly what I needed, it is running just fine.

Greetings,
Cristian

Offline

Board footer

Powered by FluxBB