export jfree chart to MSWord

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
chinmay
Posts: 4
Joined: Wed Jul 16, 2008 5:47 pm

export jfree chart to MSWord

Post by chinmay » Sun Jul 20, 2008 4:11 pm

Hi,

In my popup windows, i have shown 3 charts.Now i want to export all charts to MSword after clicking a button.

Please suggest me how i achieve that.

i.e i want to save the all charts in the pop up windows into word format.

Please reply me as soon as possible.

Thanks
Chinmay

sreehari.ojili
Posts: 14
Joined: Tue May 06, 2008 5:57 am

Post by sreehari.ojili » Mon Jul 21, 2008 12:51 pm

i guess, we cant directly exports reports into word format, we can achieve this by exporting report into RTF format, most of word processors support RTF format.

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Post by RichardWest » Mon Jul 21, 2008 5:47 pm

Microsoft's DOC format is a proprietary format. RTF (Rich Text Format) is also a Microsoft proprietary format, but it is open in as much as the specification has been released. In both cases, the file formats only describe text or textural documents. Neither encode image data. What you need to do is use JFreeChart's built in functionality to export charts to PNG or JPEG which can be included/imported/referenced in a DOC or RTF file.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Tue Jul 22, 2008 1:36 pm

Well, not fully true: RTF *can* contain images - but it is a mess. An easy way to create RTF-documents is to use iText to build up your document and to include AWT-images in the document.

So:

(1) Create images from your charts
(2) Create the iText-document and insert the images there.
(3) Save the doc, and word should be able to pick it up.

The iText documentation contains all information needed to start with generating RTF documents.

Locked