Generating DOC file using BIRT RE API [message #657174] |
Tue, 01 March 2011 14:35  |
Eclipse User |
|
|
|
Hello,
I was wondering if anyone can help me with this issue.
I was not able to find much documentation on how to create a DOC file using the BIRT RE API.
I have a very simple stand alone JAVA application that uses the BIRT RE API. The code I have, based on my online research is:
----------------------
EngineConfig config = new EngineConfig( );
//Set the logging directory.
String directoryName=null;//when set to null, will log to std out.
config.setLogConfig(directoryName, Level.FINE);
//Start the platform to load the appropriate plugins.
//If using RE API in Eclipse/RCP application this is not needed.
Platform.startup( config );
//
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
engine.changeLogLevel( Level.WARNING );
//Load the report.
IReportRunnable report = engine.openReportDesign("C:\\BIRT_MySQL\\test\\CustomersToEmployees.rptdesign ");
String reportName=report.getReportName();
System.out.println("ReportName=" + reportName);
//Create task to run the report - use the task to execute the report and save to disk.
IRunAndRenderTask task = engine.createRunAndRenderTask(report);
//Set the RenderOption to create a DOC file into the task.
IRenderOption options = new RenderOption();
options.setOutputFileName("C:\\BIRT_MySQL\\test\\CustomersToEmployees.doc ");
options.setOutputFormat("doc");
task.setRenderOption(options);
//run and render report
task.run();
task.close();
//
engine.destroy();
Platform.shutdown();
----------------------
The code does generate the DOC file. When I double click on the generated DOC file, the DOC file opens up and shows contents nicely on my Word 2003.
As another test, when I emailed this file to myself using gmail, and tried to open it using the Google Docs, I get the following error message:
"This file could not be imported because the version of this file format is unsupported."
I have opened up other Word DOCs fine within gmail without any problems.
Does anyone know if I need to set a version within the code? If so, how would I do it? Or, do I need to make other method calls?
Thanks so much in advance,
--Anna
|
|
|
Re: Generating DOC file using BIRT RE API [message #657198 is a reply to message #657174] |
Tue, 01 March 2011 16:59   |
Eclipse User |
|
|
|
Anna,
The word emitter uses WordML xml format. I am not certain google docs
supports this.
Jason
On 3/1/2011 2:35 PM, Anna T. wrote:
> Hello,
>
> I was wondering if anyone can help me with this issue.
> I was not able to find much documentation on how to create a DOC file
> using the BIRT RE API.
> I have a very simple stand alone JAVA application that uses the BIRT RE
> API. The code I have, based on my online research is:
>
> ----------------------
> EngineConfig config = new EngineConfig( );
>
> //Set the logging directory.
> String directoryName=null;//when set to null, will log to std out.
> config.setLogConfig(directoryName, Level.FINE);
>
> //Start the platform to load the appropriate plugins.
> //If using RE API in Eclipse/RCP application this is not needed.
> Platform.startup( config );
>
> //
> IReportEngineFactory factory = (IReportEngineFactory) Platform
> .createFactoryObject(
> IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
> engine = factory.createReportEngine( config );
> engine.changeLogLevel( Level.WARNING );
>
> //Load the report.
> IReportRunnable report =
> engine.openReportDesign("C:\\BIRT_MySQL\\test\\CustomersToEmployees.rptdesign
> ");
> String reportName=report.getReportName();
> System.out.println("ReportName=" + reportName);
>
> //Create task to run the report - use the task to execute the report and
> save to disk.
> IRunAndRenderTask task = engine.createRunAndRenderTask(report);
>
> //Set the RenderOption to create a DOC file into the task.
> IRenderOption options = new RenderOption();
> options.setOutputFileName("C:\\BIRT_MySQL\\test\\CustomersToEmployees.doc ");
>
> options.setOutputFormat("doc");
> task.setRenderOption(options);
>
> //run and render report
> task.run();
> task.close();
> //
> engine.destroy();
> Platform.shutdown();
> ----------------------
>
> The code does generate the DOC file. When I double click on the
> generated DOC file, the DOC file opens up and shows contents nicely on
> my Word 2003.
>
> As another test, when I emailed this file to myself using gmail, and
> tried to open it using the Google Docs, I get the following error message:
> "This file could not be imported because the version of this file format
> is unsupported."
>
> I have opened up other Word DOCs fine within gmail without any problems.
>
> Does anyone know if I need to set a version within the code? If so, how
> would I do it? Or, do I need to make other method calls?
>
> Thanks so much in advance,
> --Anna
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03337 seconds