Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
CSV emitter doesn't work as separate Render Task
keithpower
Hi all,
I can successfully render to CSV by doing a single RunAndRenderTask, but I want to render to PDF, CSV and HTML at once, without re-running the queries in my reports.
The HTML and PDF export just fine, but the CSV file is blank. I'm using BIRT 2.2.1, and not using the WebViewer. Here's the rendering code I'm using:
//Create Render Task
IRenderTask renderTask = engine.createRenderTask(rptDoc);
// set up rendering uptions for CSV
CSVRenderOption optionsCSV = new CSVRenderOption();
optionsCSV.setOutputFormat( CSVRenderOption.CSV );
optionsCSV.setOutputFileName(outputFilePathCSV);
renderTask.setRenderOption(optionsCSV);
// render
renderTask.render();
// set up rendering uptions for PDF
HTMLRenderOption optionsPDF = new HTMLRenderOption();
optionsPDF.setOutputFileName(outputFilePathPDF);
optionsPDF.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_PDF);
renderTask.setRenderOption(optionsPDF);
// render
renderTask.render();
HTMLRenderOption optionsHTML = new HTMLRenderOption();
optionsHTML.setOutputFileName(outputFilePathHTML);
optionsHTML.setOutputFormat(HTMLRenderOption.OUTPUT_FORMAT_HTML);
renderTask.setRenderOption(optionsHTML);
// render
renderTask.render();
renderTask.close();
I've tried placing the CSV render Task first and last but all I get is an empty file.
Anyone come across this before ? Can you shed any light ?
Many thanks,
Keith
Find more posts tagged with
Comments
keithpower
I found the solution to this. The CSV emitter doesn't use a separate RenderTask, it uses a DataExtractionTask.<br />
<br />
There's an example at:<br />
<br />
<a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php#idataextractiontask'>Report
Engine API</a><br />
<br />
<br />
Cheers,<br />
<br />
Keith
keithpower
Hi again,
Using the example DataExtractionTask referred to above I was able to pull out the tables, and better, I could also pull out data from charts, something the CSV emitter doesn't do.
However, I can't get access to any of the labels that are in the report. The CSV emitter exports these.
Does anyone know how I can do this ? Do I have to implement a renderer and extraction task ? If so, shouldn't the CSV emitter just provide the RenderTask ? Maybe it does...
Many thanks for any help you can lend,
Keith
keithpower
Hi again,
I've been reading through the source of the CSV emitter and checking the ReportEngine logs and I've ascertained that when I use the runAndRenderTask the following message is logged:
[CSVReportEmitter] Start emitter.
but this isn't logged when I use separate RunTask and RenderTasks.
This message is logged from the start() method of the CSVReportEmitter class, so I must assume start() isn't being called by RenderTask for some reason. The initialise() method is being called though since the output file is being created.
I'll dig deeper and see what I can find...
cheers,
Keith
keithpower
Hi again,
I checked the BIRT code out from CVS and I've been tracing through it to find out what could be different from the RunAndRender Task approach and the separate RunTask and RenderTask.
The short answer is that the first way pagination defaults to true, but the second way pagination is processed only for 3 specific values. The problem is the value is null, so processing doesn't happen.
To correct this you need to set a value for pagination in the CSV emitters plugin.xml, e.g. like so:
<plugin>
<extension
name="Engine CSV Emitters"
point="org.eclipse.birt.report.engine.emitters">
<emitter
class="org.eclipse.birt.report.engine.emitter.csv.CSVReportEmitter"
format="csv"
pagination="no-pagination"
id="org.eclipse.birt.report.engine.emitter.csv"
mimeType="text/csv"/>
</extension>
</plugin>
Now rebuild the plugin jar and that should do it. It works now for me.
I've spent enough time investigating this so I'd prefer if someone involved with the project submitted the bug & fix. If you do please post here saying so. Otherwise I'll get around to it when I can.
Cheers,
Keith
keithpower
For completeness I've opened a bug for this issue (<a class='bbc_url' href='
https://bugs.eclipse.org/bugs/show_bug.cgi?id=255493)'>https://bugs.eclipse.org/bugs/show_bug.cgi?id=255493)</a>
. <br />
<br />
cheers,<br />
<br />
Keith