2 Replies Latest reply on Mar 28, 2011 10:42 AM by Wolfgang Killinger

    Seam excel export

    Walt Corey Newbie

      I am running a relatively simple seam richfaces application.


      I created a new tab and I include a form with a rich:datatable followed by an h:commandLink to export the table contents as an Excel spreadsheet.


      When I depress the 'Export to Excel link from all appearances it does something as the completion bar of Firefox moves, stops, then completes the move before the page is rerendered. However I am never presented with the popup window on what to do with the downloaded attachment.


      I have ensured the seam-excel and seam-jxl jars are in the web-inf/lib. I have updated the web.xml to add Document Store Servlet and the mapping to it for xls files.


      Below is the tab. BTW, this is a war generating seam app running under jboss 5.1.0.GA. There are no errors.


      Any suggestions would be greatly appreciated.


      thanks,
      Walt



           <rich:tab name="active">
               <f:facet name="label">
                   <h:panelGroup>Active (#{DailyActivity.resultList.size()} days)</h:panelGroup>
              </f:facet>
                <h:form id="excelExport">
                     <rich:panel id="activeCount">
                          <rich:dataTable value="#{DailyActivity.resultList}" var="_day"
                          rendered="#{!empty DailyActivity.resultList}" id="excelTable"
                          style="xls-font: 10 Verdana; xls-column-widths: 8000 8000"
                          columnClasses="left, right" width="500px">
                          
                          <rich:column>
                               <f:facet name="header">
                                    <h:outputText value="Date" />
                               </f:facet>
                               <h:outputText value="#{_day.date}" />
                          </rich:column>
                          <rich:column>
                               <f:facet name="header">
                                    <h:outputText value="Active" />
                               </f:facet>
                               <h:outputText value="#{_day.active}" />
                          </rich:column>
                          </rich:dataTable>
                          <h:commandLink value="Export to Excel Spreadsheet"
                               rendered="#{!empty DailyActivity.resultList}"
                               action="#{org.jboss.seam.excel.exporter.excelExporter.export('excelExport:excelTable')}"/>
                     </rich:panel>
                </h:form>
           </rich:tab>
      




        • 1. Re: Seam excel export
          Walt Corey Newbie

          What I had in the action bean scope was ScopeType.CONVERSATION.


          I don't know why this is and I don't know if it has to be this way, as I saw nothing in Chapter 19 on this but I discovered the only difference between the sample seam-excel app and mine was in the former it had ScopeType.SESSION. It was also an ear type project. I didn't see any rationale for that so I made a facsimile of that example web app as a war artifact type project and it worked just fine. I next changed the ScopeType to CONVERSATION and, surprisingly, it also failed to work, no warnings, no errors just no dialog box of where to store or open the created xls or csv file.


          I next changed the scope in my application to SESSION and, lo and behold, it presented the dialog box of what to do with the output and, in fact, the output was properly formatted as an xls.


          Would someone explain this as I, and I suspect other, would want to know the distinction? I thought ScopeType.CONVERSATION was a superset of SESSION.


          Thanks,
          Walt

          • 2. Re: Seam excel export
            Wolfgang Killinger Newbie

            This makes me wonder as in my case the CONVERSATION scope does not cause a problem.


            But I face a differnt problem: The rich:table, which is surrounded by a h:form is converted fairly well in an Excel sheet. But if I include the xhtml-file containing the table into another xhtml-file with ui:include, then just nothing happens if the user clicks on the commandlinkg. The surrounding xhtml-file has its own h:form so that I have to nested forms. I tried to specify the outer form instead of the inner one, but this changes nothing. Also I tried to combine the forms in this way:


            <rich:panel>
                           <f:facet name="header">
                                <s:fragment>
                                     <h:commandLink target="_blank"
                                          action="#{ org.jboss.seam.excel.exporter.excelExporter.export('selection:resultForm:resulttable') }" >
                                     </h:commandLink>
                                </s:fragment>
                           </f:facet>


            but this still changes nothing. So I suspect, that the nested structure of the ui:include prohibits the excelExporter to work properly. Is there an option to get this straight.


            Thanks for any suggestions,
            Wolfgang