Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Auto-Saving Reports
Lianite
Greetings,
Currently the team I am a part of has a tomcat server hosting our BIRT engine. What we would like to be able to do is set up timers to run certain reports and save those reports as PDF files on our server. Is there any way to do this?
Thank you,
Jordan Trulen
Find more posts tagged with
Comments
Lianite
Alright, no takers. I have been reading about outputting a rptdocument instead, how would I go about doing this? I am using BIRT 2.5.0 RCP Designer and a Tomcat server. Ideally, I want to setup a crontab on our server to output the rptdocument daily so our users can run the document into pdf form.
Thank you.
rhcp
I need to be able to do something like just like this. Ideally I would like to have the output be an .xls file. But I am looking to having a report run everyday and exported/saved somewhere. Any input would be nice. We are running 2.3.0 on tomcat5.5 just fyi.
Thanks
rhcp
jtrulen:<br />
<br />
I think that I found something that might help you if you are still looking.<br />
<br />
<a class='bbc_url' href='
http://eclipser-blog.blogspot.com/2008/02/automatic-generation-of-birt-reports.html'>eclipser-blog
: Automatic generation of BIRT reports</a>
rhcp
jtrulen: I am guessing you might not need this, but there might be others that need it. I have a java solution for this problem.<br />
<a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php'>Report
Engine API</a><br />
<br />
<br />
package report;<br />
import java.util.logging.Level;<br />
<br />
import org.eclipse.birt.core.framework.Platform;<br />
import org.eclipse.birt.report.engine.api.*;<br />
import org.eclipse.birt.report.engine.dataextraction.CSVDataExtractionOption;<br />
<br />
public class TestReportEngine {<br />
<br />
public static void main(String[] args) {<br />
// EngineConfig config = new EngineConfig( );<br />
// config.setEngineHome( "put engine path here" );<br />
EngineConfig config = null;<br />
IReportEngine engine = null;<br />
try{<br />
config = new EngineConfig( );<br />
//onfig.setEngineHome( "/birt-runtime-2_3_0/birt-runtime-2_3_0/ReportEngine" ); // this is the birt_home location have to install on server<br />
config.setEngineHome( "WebContent/WEB-INF/platform" );<br />
<br />
config.setLogConfig("c:/temp", Level.FINE);<br />
<br />
Platform.startup( config ); //If using RE API in Eclipse/RCP application this is not needed.<br />
IReportEngineFactory factory = (IReportEngineFactory) Platform<br />
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );<br />
engine = factory.createReportEngine( config );<br />
engine.changeLogLevel( Level.WARNING );<br />
<br />
}catch( Exception ex){<br />
ex.printStackTrace();<br />
}<br />
// Run reports, etc.<br />
//Open a report design <br />
<br />
IReportRunnable design = null;<br />
try {//ie. C:OUTPUTFILE, /WebContent/report<br />
//design = engine.openReportDesign("C://birt-runtime-2_3_0//birt-runtime-2_3_0//ReportEngine//rejectClosingWithinWeek.rptdesign");<br />
design = engine.openReportDesign("WebContent/report/rejectClosingWithinWeek.rptdesign");<br />
} catch (EngineException e) {<br />
System.out.println("Error opening design file.");<br />
e.printStackTrace();<br />
} <br />
<br />
//Create task to run the report - use the task to execute the report and save to disk.<br />
IRunTask task = engine.createRunTask(design); <br />
//Set parent classloader for engine //RunTaskExample.class.getClassLoader()<br />
task.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, RejectData.class.getClassLoader()); <br />
<br />
//run the report and destroy the engine<br />
try {<br />
task.run("C:worktestSOX.rptdocument");<br />
} catch (EngineException e) {<br />
System.out.println("Error running IRunTask.");<br />
// TODO Auto-generated catch block<br />
e.printStackTrace();<br />
} <br />
<br />
task.close();<br />
<br />
<br />
//Open a report document <br />
IReportDocument iReportDocument = null;<br />
try {<br />
iReportDocument = engine.openReportDocument("C:worktestSOX.rptdocument");<br />
} catch (EngineException e1) {<br />
System.out.println("Error openning iReportDocument (we just created this).");<br />
e1.printStackTrace();<br />
}<br />
//Create Render Task<br />
IRenderTask taskXLS = engine.createRenderTask(iReportDocument);<br />
//Set parent classloader report engine<br />
taskXLS.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY,RejectData.class.getClassLoader()); <br />
<br />
IRenderOption options = new RenderOption(); <br />
<br />
options.setOutputFormat("xls");<br />
options.setOutputFileName("output.xls");<br />
<br />
<br />
if( options.getOutputFormat().equalsIgnoreCase("html")){<br />
HTMLRenderOption htmlOptions = new HTMLRenderOption( options);<br />
htmlOptions.setImageDirectory("output/image");<br />
htmlOptions.setHtmlPagination(false);<br />
//set this if you want your image source url to be altered<br />
//If using the setBaseImageURL, make sure to set image handler to HTMLServerImageHandler<br />
htmlOptions.setBaseImageURL("
http://myhost/prependme?image=");<br
/>
<br />
htmlOptions.setHtmlRtLFlag(false);<br />
htmlOptions.setEmbeddable(false);<br />
}else if( options.getOutputFormat().equalsIgnoreCase("pdf") ){<br />
<br />
PDFRenderOption pdfOptions = new PDFRenderOption( options );<br />
pdfOptions.setOption( IPDFRenderOption.FIT_TO_PAGE, new Boolean(true) );<br />
pdfOptions.setOption( IPDFRenderOption.PAGEBREAK_PAGINATION_ONLY, new Boolean(true) );<br />
<br />
}else if( options.getOutputFormat().equalsIgnoreCase("xls") ){<br />
<br />
EXCELRenderOption xls = new EXCELRenderOption(options);<br />
xls.setOption(IExcelRenderOption.OFFICE_VERSION, new Boolean(true));<br />
xls.setOption(IExcelRenderOption.WRAPPING_TEXT, new Boolean(false));<br />
}<br />
//Use this method if you want to provide your own action handler<br />
//options.setActionHandler(new MyActionHandler());<br />
<br />
//file based images<br />
//options.setImageHandler(new HTMLCompleteImageHandler())<br />
//Web based images. Allows setBaseImageURL to prepend to img src tag<br />
//options.setImageHandler(new HTMLServerImageHandler());<br />
<br />
IRenderTask finalTask = engine.createRenderTask(iReportDocument); <br />
finalTask.setRenderOption(options);<br />
//finalTask.setPageRange("1-2");<br />
try {<br />
finalTask.render();<br />
} catch (EngineException e) {<br />
System.out.println("Error running IRenderTask (saving the report).");<br />
e.printStackTrace();<br />
}<br />
iReportDocument.close();<br />
<br />
engine.destroy();<br />
Platform.shutdown(); <br />
<br />
}<br />
<br />
}