This post gives you the easy and simplest way to export the pivot table data to excel file. For normal af:table there is exportListener used to export the table data to excel. But for dvt:pivotTable there is dvt:exportPivotTableData is available. (sample project attached below)
dvt:exportPivotTableData gives the two options like to export the whole data also to export the selected data
exportedData="selected" - to export selected data from the pivot table.
exportedId - refers to the pivot talbe component Id.
I have created a pivot table with a format shows the Department vs Job Id with the related counts of employees in department and sum salary of them,
In the jspx, I added the export listener to the command button, one to export all, and another to export selected data.
<af:panelGroupLayout id="pgl0" >
<af:commandButton text="Export All" id="exportAll">
<dvt:exportPivotTableData exportedId="pivotTable1" type="excelHTML"
exportedData="all" filename="all.xls"
title="All pivotTable data"/>
</af:commandButton>
<af:commandButton text="Export Selected" id="exportSelected">
<dvt:exportPivotTableData exportedId="pivotTable1" type="excelHTML"
exportedData="selected" filename="selected.xls"
title="Selected pivotTable data"/>
</af:commandButton>
<dvt:pivotTable id="pivotTable1" summary="" inlineStyle="width:600px;"
binding="#{readpagedefbean.pivottable}"
value="#{bindings.HrMatrix1.pivotTableModel}"/>
</af:panelGroupLayout>
On click of Export all button,
Download sample code here (Run the PivotTable.jspx , uses Oracle XE - HR schema).
dvt:exportPivotTableData gives the two options like to export the whole data also to export the selected data
<dvt:exportPivotTableData
exportedId="pivotTable1" type="excelHTML"
here,
exportedData="all" - to export the all the data
from the pivot table.
exportedId - refers to the pivot talbe component Id.
I have created a pivot table with a format shows the Department vs Job Id with the related counts of employees in department and sum salary of them,
In the jspx, I added the export listener to the command button, one to export all, and another to export selected data.
<af:panelGroupLayout id="pgl0" >
<af:commandButton text="Export All" id="exportAll">
<dvt:exportPivotTableData exportedId="pivotTable1" type="excelHTML"
exportedData="all" filename="all.xls"
title="All pivotTable data"/>
</af:commandButton>
<af:commandButton text="Export Selected" id="exportSelected">
<dvt:exportPivotTableData exportedId="pivotTable1" type="excelHTML"
exportedData="selected" filename="selected.xls"
title="Selected pivotTable data"/>
</af:commandButton>
<dvt:pivotTable id="pivotTable1" summary="" inlineStyle="width:600px;"
binding="#{readpagedefbean.pivottable}"
value="#{bindings.HrMatrix1.pivotTableModel}"/>
</af:panelGroupLayout>
On click of Export all button,
On click of Export selected button,
Download sample code here (Run the PivotTable.jspx , uses Oracle XE - HR schema).
This comment has been removed by a blog administrator.
ReplyDeleteExample is very nice. This exactly suite for my requirement. Many thanks for publishing this article. Thanks a lot
ReplyDeletePrashanth Kumar
ADF Architect
Zensar Technologies
Hi Gopinath,
ReplyDeleteIt is not working on fragments in JDEV 12.1.3 I have tried.
Thanks