Generating DOC file using BIRT RE API [message #657174] |
Tue, 01 March 2011 19:35 |
anna.w.teittinen Messages: 23 Registered: February 2011 |
Junior Member |
|
|
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 21:59 |
|
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
|
|
|
|
Re: Generating DOC file using BIRT RE API [message #657212 is a reply to message #657207] |
Tue, 01 March 2011 22:58 |
|
Anna,
The format is a word 2003 format and will not open in earlier versions
of word.
Jason
On 3/1/2011 5:51 PM, Anna T. wrote:
> Hello Jason,
>
> I asked a friend of mine who has Microsoft Word 2002 to try to open the
> DOC file (that I generated using the RE API).
>
> This time, a Microsoft Word dialog came up with the following error:
> "Word cannot start the converter mswrd632.wpc."
>
> Does anybody recognize this error message?
>
> So, for some reason, the DOC file opens fine in Word 2003 but not in
> Word 2002 nor Google Docs.
>
> Has anyone successfully created a DOC file using the RE API?
>
> Thanks so much,
> --Anna
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04361 seconds