This discussion is archived
4 Replies Latest reply: Aug 26, 2013 12:23 AM by 1012433 RSS

How to achieve exporto excel format using managed bean class?

1012433 Newbie
Currently Being Moderated


I am using jdev11.



My requirement is get excel sheet using bean class calling


In first case i develop one user defined component which is named as global component is under component pallete in this component i have

different image icons which for save,insert,excel.....for excel image i drag exportcollectionactionlistener drop on  excel image this is one projecet

name as globalcomponent


after that i have another project which isnamed as admin project add my global project to admin


in this admin page i have one master top on this page i got icons excel,save like etc... in this case of excel i call actiolistener class to call method

to get excel attachment in download way..


My code is in action listener is like this


public void exportToExcel(ActionEvent actionEvent) throws IOException
String filename = "CurrencyList.xls";
FacesContext fc = FacesContext.getCurrentInstance();
BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry();
// get response object.
HttpServletResponse response = (HttpServletResponse)fc.getExternalContext().getResponse();
// Set the file name
response.setHeader("Content-disposition", "attachment; filename=" + filename);
// Set MIME type to excel
PrintWriter out = response.getWriter();


DCIteratorBinding theateriter = (DCIteratorBinding)bc.get("pofAdminCurrencyViewIterator");   //pofAdminCurrencyViewIterator




/*  DCIteratorBinding areaiter = (DCIteratorBinding)bc.get("MyVO2Iterator");
public void printtoexcel(DCIteratorBinding iter, PrintWriter out)
RowSetIterator rsi = iter.getRowSetIterator();
String[] attNames = rsi.getRowAtRangeIndex(0).getAttributeNames();
for (int i = 0; i < attNames.length-1; i++) {
if (i > 0)
out.print("\t"); // tab after each value






my UI Code




<pofGC:pofGlobalComp id="pgc1"

                       saveCall="#{POFAdminCurrencyBean.doCommit}" firstCall="#{bindings.First.execute}" currPage="Currency Page"






                       lastCall="#{bindings.Last.execute}" nextCall="#{bindings.Next.execute}"

                       previousCall="#{bindings.Previous.execute}" excelCall="#{pofAdminMainActionBean.exportToExcel}">




  • Correct Answers - 10 points
  • Helpful Answers - 5 points