Data of the collection components in ADF such as table, tree or treeTable can easily be exported in the form of xls file using ADF exportCollectionActionListener tag. It allows action events to export data from the colleection component.
<af:exportCollectionActionListener/> id attribute will refer to the collection component Id.
Find the sample code snippet for exporting department table records.
<af:panelCollection id="pc1" styleClass="AFStretchWidth">
<f:facet name="toolbar">
<af:toolbar id="t2">
<af:commandToolbarButton text="Export" id="ctb1">
<af:exportCollectionActionListener type="excelHTML"
exportedId="table"
filename="DepartmentExcel"/>
</af:commandToolbarButton>
</af:toolbar>
</f:facet>
<af:table id="table" ....
.................................. ...................
............ >
</af:panelCollection>
By default the extension of the file downloaded will be xls. We can also export the record in doc format by just giving name of a file such as DepartmentExcel.doc in the attribute filename.
*Comments and feedback are most welcomed, Thanks.
How do you import that Excel data now back into your ADF table (database)?
ReplyDeleteGreg,
ReplyDeleteTo import excel back to the ADF table you can use file upload component and will require some coding to parse it.
Pasted link for reading excel using java:
http://www.vogella.com/tutorials/JavaExcel/article.html
Hi Gopal,
ReplyDeleteIs there a way to directly export to excel from the data control on button click?
Thanks
Ray
Ray,
ReplyDeleteYou can also use af:fileDownloadActionListener with command button. Specify content type as "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
And add custom method to read Iterator using java and export to excel
Hi,
ReplyDeleteIn adf table , one of the column has stiosignal with hovertext for it and number beside it in same column. But when i export it to excel i want only number to displayed in that column. But issue is both hovertext and number is displaying in that column.PLaese do nsome needful.
Thanks