cancel
Showing results for 
Search instead for 
Did you mean: 

Export search results into Excel file

chiranjeevi
Champ in-the-making
Champ in-the-making
Hi,

   Is it possible to export the search results into excel file?

  Thanks in Advance.
8 REPLIES 8

manish17
Champ in-the-making
Champ in-the-making
Did u get this, how to export search results into Excel. If yes, please respond to this.

cheffilet
Champ in-the-making
Champ in-the-making
Please take a look to the ContentTransformers Section.

At a glance please open tomcat\webapps\alfresco\WEB-INF\classes\alfresco\content-services-context.xml and have a look to following snippet:

<bean id="transformer.Poi"
         class="org.alfresco.repo.content.transform.PoiHssfContentTransformer"
         parent="baseContentTransformer" />

One transformer, responsible to change excel input into a string.

See therefore: org.alfresco.repo.content.transform.PoiHssfContentTransformer.transformInternal.

Now you get a first expierence on how an excel format can be read.

But in which way we can achieve your aim? If you do a search, nodes will be stored in the backend as an attribute "contentNodes" member of BrowseBean.

Your only thing you have to make is, to create an excel download button what delegates the "download request" to a downdload servlet. This Servlet obtains the BrowseBean via BeanFactory as the browsbean is managed within the whole session. Now you can query getNodes() on that class and you retrieve your last search results.

A more better solution can be achieved on querieng alfresco within the servlet as well.

Happy Coding!
Best Regards!

chiranjeevi
Champ in-the-making
Champ in-the-making
Thanks Cheffilet.

    I am new to Alfresco coding.

    Can you please tell me how to add download button in search results screen?
    and how to invoke download servlet when I click on download button?

    Thanks in Advance!

luckyo
Champ in-the-making
Champ in-the-making
you should add some link for "download" at browse.jsp Page.

( Becasue in "AdvanceSearchDialog.java will return result to browse.jsp" )

and this like will call servlet "reportServlet" and you have to add this on web.xml

Then you have to some coding about getting data from browseBean.

But My idea is so hard way, But i have not idea to use WEBDev too.

Cheer

esource
Champ on-the-rise
Champ on-the-rise
thank you for your posts.  They have been very helpful!

jlaww
Champ in-the-making
Champ in-the-making
Hi,
I want to export the search result into excel file or .csv file.
I added a link, for "download", to "browse.jsp" but I don't know some coding about getting data from browseBean.

Code for add actionLink to browse.jsp

<td style="padding-left:4px" width=90>
<nobr><a:actionLink id="link22" style="white-space:nowrap" value="Exportar CSV" actionListener="#{CSVExportAction.csvExport}" image="/images/icons/export.gif">
</a:actionLink></nobr>
</td>

Bean code to identify the action with their sources. I added the following code to the file: faces-config-custom.xml


<faces-config>
   <managed-bean>
        <description>
                Exporta a un fichero CSV, los metadatos de los documentos obtenidos en la búsqueda
        </description>
        <managed-bean-name>
                CSVExportAction
        </managed-bean-name>
        <managed-bean-class>
                ants.alfrescoexportcsv.csvexportaction.CSVExportAction
        </managed-bean-class>
        <managed-bean-scope>
                session
        </managed-bean-scope>
         <managed-property>
                <property-name>nodeService</property-name>
                <value>#{NodeService}</value>
        </managed-property>
        <managed-property>
                <property-name>browseBean</property-name>
                 <value>#{BrowseBean}</value>
        </managed-property>
    </managed-bean>
</faces-config>

Code Java Class export search results into Excel file


public class CSVExportAction extends ActionExecuterAbstractBase{
   
   private static Logger logger;
      
   public CSVExportAction (){
      super();
   }
   
   private NodeService nodeService;
   private BrowseBean browseBean;
   
   public BrowseBean getBrowseBean() {
      return browseBean;
   }

   public void setBrowseBean(BrowseBean browseBean) {
      this.browseBean = browseBean;
   }

   public NodeService getNodeService() {
      return nodeService;
   }

   public void setNodeService(NodeService nodeService) {
      this.nodeService = nodeService;
   }
       ….
       public void csvExport(ActionEvent e) throws Exception{
           // Start the session
      this.initLog();
      logger.info("init exportCSV");
      logger.debug("BroseBean: "+browseBean);
      logger.debug("NodeService: "+nodeService);
      List<Node> nodos = browseBean.getNodes();
      logger.info("Size List "+nodos.size());
      for(int i = 0 ; i<nodos.size();i++)
          logger.debug("NODO: "+nodos.get(i));
      ….
       }
….
      protected void executeImpl(Action arg0, NodeRef arg1) {
      }

     protected void addParameterDefinitions(List arg0) {
     }
}

Error System of link in actionLink for export search result


javax.faces.FacesException: net.sf.acegisecurity.providers.ProviderNotFoundException: No authentication provider for net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken
caused by:
org.apache.jasper.JasperException: net.sf.acegisecurity.providers.ProviderNotFoundException: No authentication provider for net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken
caused by:
net.sf.acegisecurity.providers.ProviderNotFoundException: No authentication provider for net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken

How I can get browseBean in my java class?
How I can pass browseBean for actionLink to browse.jsp?

Thanks

scot84
Champ in-the-making
Champ in-the-making
To avoid that error add this line of code at the end of csvExport metod

browseBean.closeSearch(e);

amarnath_v_l
Champ in-the-making
Champ in-the-making
hi all.
did any one get how to export search result in to excel sheet?