Showing posts with label af:exportCollectionActionListener. Show all posts
Showing posts with label af:exportCollectionActionListener. Show all posts

Tuesday, November 2, 2010

ADF UI - Implementing 'Export to Excel' functionality

Here, we'll see how to implement 'Export to Excel' functionality for ADF tables. For example you have a search results table and you want to export the search results to excel sheet on clicking the button 'Export to Excel'.

To implement this, Drag and drop <af:exportCollectionActionListener> on 'Export to Excel' button. and specify exportedId="<search_results_table_id>" and type="excelHTML". Give fileName="excel_file_name.xls" and title="excel_sheet_name_within_excel_file".


The 'Export to Excel' toolbar button in 'Structure' window:

Here is the code:
<af:commandToolbarButton text="Export to Excel" id="commandToolbarButton2" disabled="#{bindings.EmpDeptVO.currentRow==null}" partialTriggers="t1"> <af:exportCollectionActionListener type="excelHTML" exportedId="t1" filename="SearchResults.xls" title="Search Results"/> </af:commandToolbarButton>

That's it. Now, when you run the page and click on 'Export to Excel' button, it'll generate the excel file and asks to open or save the Excel.

Enjoy!!
Related Posts with Thumbnails