Customizing buttons for one-step exporting
Seven buttons are provided for one-step exporting. They are Export to PDF, Export to Excel, Export to RTF, Export to HTML, Export to Text, Export to PS, and Export to XML. By default, the buttons are invisible on the toolbar area. You have to add them to the toolbar area by modifying the index.jsp file in <install_root>\public_html\dhtmljsp
.
Use the following two API functions to control the buttons:
- public void customizeToolbar(String SessionId, String RptSetId, String toolbarname, int[] buttonId);
- public void customizeToolbar(String SessionId, String RptSetId, String toolbarname, int[] buttonId, boolean isVisible);
Explanation of these parameters:
- SessionId - session ID, which can be retrieved by DHTMLUtil.getSessionID(request).
- RptSetId - report ID, which can be retrieved by obDHTMLUtil.getRptSetId(request).
- toolbarname - toolbar name, such as "Standard", "Analysis", "View", or user-defined ones.
- buttonId[] - toolbar button ID. It is an integer array, so you need define an integer array variant.
For example: int[] mybuttonid ={DHTMLConstant.TOOLBAR_EXPORTTOPDF, DHTMLConstant.TOOLBAR_EXPORTTOXLS, TMLConstant.BTN_EXPORT_TO_RTF}
The array elements available for one-step exporting are:
- DHTMLConstant.TOOLBAR_EXPORTTOPDF
- DHTMLConstant.TOOLBAR_EXPORTTOXLS
- DHTMLConstant.TOOLBAR_EXPORTTORTF
- DHTMLConstant.TOOLBAR_EXPORTTOHTML
- DHTMLConstant.TOOLBAR_EXPORTTOTEXT
- DHTMLConstant.TOOLBAR_EXPORTTOPS
- DHTMLConstant.TOOLBAR_EXPORTTOXML
- isVisible - whether or not to show the buttons defined with buttonID[]. true -- show, false -- hide. This parameter can be absent, and then the value is true.
For example, if you want to add the Export to HTML button to the Export toolbar, then:
- Open the file index.jsp.
- Add the code
int[] temparray = {DHTMLConstant.TOOLBAR_EXPORTTOHTML};
dhtmlConfig.customizeToolbar(SessionID, RptSetId, "Standard", temparray, true);
before
//<!-- Tool Bar -->
if(dhtmlConfig.isFeatureEnabled(SessionID, RptSetId, DHTMLConstant.FEATURE_TOOLBAR)){
- Start JReport Server.
- Run a report in Page Report Studio, and you will see a new button Export to HTML is displayed on the Export toolbar.
To add more than one button to the toolbar area, for example, adding Export to HTML and Export to PDF buttons to the Export toolbar:
- Open the file index.jsp.
- Add the code
int[] temparray = {DHTMLConstant.TOOLBAR_EXPORTTOHTML, DHTMLConstant.TOOLBAR_EXPORTTOPDF};
dhtmlConfig.customizeToolbar(SessionID, RptSetId, "Standard", temparray, true);
before
//<!-- Tool Bar -->
if(dhtmlConfig.isFeatureEnabled(SessionID, RptSetId, DHTMLConstant.FEATURE_TOOLBAR)){
- Start JReport Server.
- Run a report in Page Report Studio, and you will see the buttons Export to HTML and Export to PDF are displayed on the Export toolbar.
- Click the added button on the toolbar of the report page, the report will be exported to the corresponding format, using the default values of the format options.