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)
Change Outputformat to Word via API
Dude
Hallo
Right now I am trying to print out my reports in several outputformats. PDF and HTML works just fine even EXCEL is no problem.
Now I would like to create a Word and PowerPoint file. But this does not work so easily.
To create an EXCEL output I just use the EXCELRenderOption class and set some property and it works. For Word or PowerPoint I could not find such class. I just find classes like WordemitterPlugin, WordEmitterDescriptor,PPTEmitter. Are these the right classes to create an Word/PowePoint output ? if these are the right ones. How do I use them? Is there a example of the usability of them?
Or is there a much easier way to get such an output?
I hope you can help me !!
Thanks
Dude
Find more posts tagged with
Comments
CBR
Hi,<br />
<br />
you are right. PPT and DOC do not have their own EmitterOption object because they do not provide any user specific configuration. That's why you have to use the generic render object. See my code below (it is part a class but you should be able to get it).<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
private IRenderOption getRenderOptionsForFormat(String fileName, OutputFormat format) {
/** in principle the options object is enough to render the report in the desired
* format, so just a quick demo of what's possible!
*/
IRenderOption options = new RenderOption();
options.setBaseURL("http://myDomain.com");
options.setSupportedImageFormats("SVG;PNG;JPG;GIF");
//provide corresponding file ending to enable BIRT to find the right emitter (ppt, pdf, doc, ...)
options.setOutputFormat(format.name().toLowerCase());
options.setOutputFileName(fileName);
if(format==OutputFormat.HTML) {
HTMLRenderOption htmlOptions = new HTMLRenderOption(options);
//when set to true there will be no html header!...default is true
htmlOptions.setEmbeddable(false);
// setup the output encoding...default is ISO
htmlOptions.setUrlEncoding( "utf-8" );
htmlOptions.setHtmlPagination( false );
htmlOptions.setImageDirectory(imageDir);
return htmlOptions;
}
else if(format==OutputFormat.PDF) {
PDFRenderOption pdfOptions = new PDFRenderOption(options);
//Set flag indicates if the font needs to be embedded...default is true
pdfOptions.setEmbededFont(true);
return pdfOptions;
}
else if(format==OutputFormat.XLS) {
EXCELRenderOption excelOptions = new EXCELRenderOption(options);
/**
* the option object exists but has no working methods, perhaps with next version
*/
excelOptions.setEnableMultipleSheet(false);
excelOptions.setHideGridlines(true);
excelOptions.setWrappingText(true);
//excelOptions.setOfficeVersion(officeVersion) exists but does nothing
return excelOptions;
}
else if(format==OutputFormat.PS) {
//no option object available here!
return options;
}
else if(format==OutputFormat.DOC) {
//no option object available here!
return options;
}
else if(format==OutputFormat.PPT) {
return options;
}
return null;
}
</pre>
Dude
Hey Thanks a lot!!
It works just fine awesome! It was to simple to figure it out ;-) Thanks
Dude
Dude
Hey there
I got one more question on this subject:
Is it possible to generate a real docx file with Birt or does Birt just support the .doc file?
Thanks for the help !!
Dude
CBR
The default BIRT doc emitter of open source version only supports generating a 2003 word doc file. The 2003 doc format is a XML format that differs from the new docx format.
That means you can only open the file with 2003 or above.
Not sure if the Word emitter in commercial version is different from the one in the open source version.
I gave google a try and it seems to be the case that you can have a third party word emitter that generates real docx. Seems to be commercial:
http://www.arctorus.com/products
I do not know of any open source or free plugin