|
|
Re: Automatically create daily reports by using a Java Application [message #671635 is a reply to message #671497] |
Wed, 18 May 2011 14:22 |
|
You can change the csv file with a little de api. take a look at the
attached.
Jason
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.model.api.DataSetHandle;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SessionHandle;
import com.ibm.icu.util.ULocale;
public class ChangeFlatFile {
public void runReport() throws EngineException
{
IDesignEngine dengine=null;
try{
DesignConfig dconfig = new DesignConfig( );
dconfig.setBIRTHome("C:/birt/birt-runtime-2_6_1/birt-runtime-2_6_1/ReportEngine ");
Platform.startup( dconfig );
IDesignEngineFactory dfactory = (IDesignEngineFactory) Platform
.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
dengine = dfactory.createDesignEngine( dconfig );
IReportRunnable design = null;
//Open the report design
SessionHandle session = dengine.newSessionHandle( ULocale.ENGLISH );
ReportDesignHandle report =
session.openDesign("Reports/FlatFile.rptdesign");
DataSetHandle dsh = report.findDataSet("Data Set");
String currentquery = (String) dsh.getProperty("queryText");
currentquery.replaceFirst("chart1.csv", "chart2.csv");
report.saveAs("output/desample/FlatFile2.rptdesign" );
report.close( );
session.closeAll(false);
Platform.shutdown();
System.out.println("Finished");
}catch( Exception ex){
ex.printStackTrace();
}
}
/**
* @param args
*/
public static void main(String[] args) {
try
{
ChangeFlatFile ex = new ChangeFlatFile( );
ex.runReport();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
}
On 5/18/2011 2:42 AM, Jochen v. B. wrote:
> Hi again,
>
> is there no way to solve my problem?
> Would appreciate every kind of help.
>
> Thanks,
> Jochen
|
|
|
Re: Automatically create daily reports by using a Java Application [message #671904 is a reply to message #671635] |
Thu, 19 May 2011 10:10 |
Jochen v. B. Messages: 7 Registered: May 2011 Location: Germany |
Junior Member |
|
|
Thank you, Jason.
I used the attached and changed the directory, rptdesgin name, data set name and source-flat-file names.
In debug mode, everything is working fine (queryText is changed correctly) until the report.saveAs("..") line.
I get the following Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at org.eclipse.birt.report.model.writer.ModuleWriterImpl.<clinit>(ModuleWriterImpl.java:241)
at org.eclipse.birt.report.model.elements.ReportDesign.getWriter(ReportDesign.java:90)
at org.eclipse.birt.report.model.api.ModuleHandle.save(ModuleHandle.java:1440)
at org.eclipse.birt.report.model.api.ModuleHandle.saveAs(ModuleHandle.java:1460)
at testsection.ChangeFlatFile.runReport(ChangeFlatFile.java:48)
at testsection.ChangeFlatFile.main(ChangeFlatFile.java:64)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 6 more
Any idea how to solve this?
Best regards,
Jochen
[Updated on: Thu, 19 May 2011 10:11] Report message to a moderator
|
|
|
Re: Automatically create daily reports by using a Java Application [message #671979 is a reply to message #671904] |
Thu, 19 May 2011 13:55 |
|
Do you have all the jars from the runtime download:
birt-runtime-2_6_2\ReportEngine\lib in your classpath?
Jason
On 5/19/2011 6:10 AM, Jochen v. B. wrote:
> Thank you, Jason.
>
> I used the attached and changed the directory, rptdesgin name, data set
> name and source-flat-file names.
> In debug mode, everything is working fine (queryText is changed
> correctly) until the report.saveAs("..") line.
>
> I get the following Exception:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/codec/binary/Base64
> at
> org.eclipse.birt.report.model.writer.ModuleWriterImpl.<clinit>(ModuleWriterImpl.java:241)
>
> at
> org.eclipse.birt.report.model.elements.ReportDesign.getWriter(ReportDesign.java:90)
>
> at
> org.eclipse.birt.report.model.api.ModuleHandle.save(ModuleHandle.java:1440)
> at
> org.eclipse.birt.report.model.api.ModuleHandle.saveAs(ModuleHandle.java:1460)
>
> at testsection.ChangeFlatFile.runReport(ChangeFlatFile.java:48)
> at testsection.ChangeFlatFile.main(ChangeFlatFile.java:64)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.codec.binary.Base64
> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> ... 6 more
>
> Best regards,
> Jochen
|
|
|
|
Powered by
FUDForum. Page generated in 0.04014 seconds