Please disable your adblock and script blockers to view this page

Search this blog

Monday, 16 June 2014

Creating and Exporting hierarchical data to excel using dvt:pivotTable & dvt:exportPivotTableData in Oracle ADF

Hello All,
This post is about exporting tree structured(hierarchical ) data to an excel file.
suppose we have export department wise detail of employees , we can achieve this in ADF using pivot table (<dvt:pivotTable>)

What is pivot tabel (oracle docs)- 
 
UIComponent class: oracle.adf.view.faces.bi.component.pivotTable.UIPivotTable
Component type: oracle.dss.adf.pivotTable.PivotTable
The Pivot Table supports the display of multiple nested attributes on a row and column header. In addition, the Pivot Table supports the ability to dynamically change the layout of the attributes displayed in the row or column headers via drag and drop pivoting.
now see the implementation part -



  • Create a Fusion Web Application using HRSchema , for this sample app i have created a view (Department Wise Employees) to export data

  • CREATE OR REPLACE FORCE EDITIONABLE VIEW "APP_USR"."DEPT_EMP" ("DEPARTMENT_NAME", "EMPLOYEE_NAME", "SALARY") AS 
      SELECT A.DEPARTMENT_NAME, B.FIRST_NAME,B.SALARY FROM DEPARTMENTS A, EMPLOYEES B WHERE A.DEPARTMENT_ID=B.DEPARTMENT_ID (+);
    

  • Prepare model using this view


  • Create a page and drop this view as pivot table (ADF Faces component) from data control


  • Now configure pivot table (set row & column attributes, insert appropriate drilling) - see the snaps




  • Now run your page and see working pivot table - here pivot table is created successfully 


  • Drop a button  and a <dvt:exportPivotTableData> under button to export pivot table

  • <af:commandButton text="Export" id="b1">
                        <dvt:exportPivotTableData type="excelHTML" exportedId="pt1" filename="Dep_Empl.xls"
                                                  title="PivotTable export"/>
                    </af:commandButton>
    

  • Run your page and click on export button and see your tree structured data in exported excel file


Cheers :) Happy Learning Sample ADF Application

7 comments :

  1. Is it possible adf pivot table using master details relationship?
    Let say in my master department table dept id 100 and in employee details table 5 employee belongs to dept id 100.same way for dept id 101 ,5 employee are there etc.My requirement is,my pivot table will dynamically show in UI separately for 10 employee one pivot table and for 5 employee another pivot table like this.

    ReplyDelete
  2. Hi
    I have a problem with pivot table scrollbar when page is right to left in Arabic locale
    have you any idea about this problem ?
    when pivot table becomes too larg and needs to scroll horizentally,the scrollbar dose not work fine,
    please check it,there is no answer for this problem.
    thanks.

    ReplyDelete
    Replies
    1. Doesn't work fine means what ?
      Is scrollbar not appearing ?

      Delete
    2. I didn't get a change to test it yet, But I'll look into it soon

      Delete
  3. The scrollbar is appearing.let's talk about a scenario.you have a pivot table with 10 columns,1 to 10,columns number 1 to 5 are visible and number 6 to 10 are out and you need to scroll left to see them.when you scroll left columns should go right but they go left too.this problem happens only when the page is right to left.

    ReplyDelete
  4. Using pivot table, can we make row as columns and column as row. For example, each employee details will be row where as employees will be columns

    ReplyDelete