JReport Result Viewer can be used to view local JReport result files generated by the JReport Engine. You can show the report result file ( .rst) and export the report result to multiple file formats and to printer by calling the Result Viewer Bean.
Before programming with the Result Viewer Bean, you need to import the classes of the Result Viewer Bean by adding the following import statements to the beginning of your program. The first import statement is added to import the bean class:
import jet.bean.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
Then, you need to create an instance.
To run with the Result Viewer Bean, you should first create an instance of it. The constructor of the Result Viewer Bean has no parameter. After the object has been created, you should then set the report name and temp path (if not set, the current path will be used).
bean = new JRResultViewer();
bean.setShowInfoLevel(bean.vDebug | bean.vError);
bean.setReportName("c:\\test\\customerlist.rst");
bean.runReport("yes");
With the Result Viewer Bean object, you can show the report result and export it to other formats or to printer. You do not need to create a bean for each report.
Note that finishing using the Result Viewer Bean, you need to call the method exit() to quit from it. This will perform some clean up work, such as deleting temporary files. It is important to free up the resources of the result file, so remember to call this method.
The Result Viewer Bean provides many useful methods. The following shows how to use the Result Viewer Bean to achieve some goals:
Exporting Report Result to Different File Formats
Getting Field Results by Listening to the Click Event