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!!

