1 2 3 4 Previous Next 52 Replies Latest reply on Mar 1, 2011 4:28 PM by psramkumar.ps.ramkumar.gmail.com

    export to pdf or excel from rich:dataTable

    infinity2heaven

      Is there any tag library that works with seam to export a rich:dataTable into a pdf or excel directly? Something like jsp display tag




        • 1. Re: export to pdf or excel from rich:dataTable
          nickarls

          There will be in 2.1


          There is a 2.x compatible version that can be found here. Check out the section on datatable export in the docs

          • 2. Re: export to pdf or excel from rich:dataTable
            infinity2heaven

            1) i downloaded your seam-excel jar, jxl jar.
            2) my page is as follows



            <h:form id="searchForm">
            <a4j:outputPanel id="searchResults">
                 <h:panelGrid styelClass="panelLayout">
                      <rich:dataTable id="searchResultsTable" rows="10"
                         columnClasses="col" value="#{fundsQuery.resultList}" var="fund"
                         sortMode="single" rowKeyVar="row">
                           <!-- removed for brevity -->
                                   <rich:column>
                           
                           </rich:column>
                           
                      </rich:dataTable>
                      <h:commandLink value="Export"                           
                            action="#{org.jboss.seam.excel.excelExporter.export('searchForm:searchResultsTable')}"/>                            
                       </h:panelGrid>
                 </a4j:outputPanel>
            </h:form>



            On click of export, I get the following error


            18:13:39,187 INFO  [STDOUT] H: null
            18:13:39,187 INFO  [STDOUT] V: null
            18:13:39,187 WARN  [JXLTemplates] Could not find cell template global, try 
            18:13:39,187 WARN  [JXLTemplates] Could not find cell template data, try 
            18:13:39,187 WARN  [JXLTemplates] Could not find cell template global, try 
            18:13:39,187 WARN  [JXLTemplates] Could not find cell template data, try 
            18:13:39,187 WARN  [JXLTemplates] Could not find cell template global, try 
            18:13:39,187 WARN  [JXLTemplates] Could not find cell template data, try 
            ...
            ...
            <same message 200 times>
            
            



            and ie popup says Cannot open file


            Any hints?

            • 3. Re: export to pdf or excel from rich:dataTable
              nickarls

              Ignore the warning, it's a bug.


              It looks like it can't hook up to the document store that serves the document. What is the URL it can't find? EAR or WAR deployment? What jboss-seam-* libraries do you include and where? Anything extra in components.xml?

              • 4. Re: export to pdf or excel from rich:dataTable

                Priya M : Try using an ordinary h:dataTable and see if that works. I'm not entirely sure rich:dataTable will work...

                • 5. Re: export to pdf or excel from rich:dataTable
                  nickarls

                  Should work. Catfight!

                  • 6. Re: export to pdf or excel from rich:dataTable

                    Cool. I just haven't found the parsing of the UIColumnGroup and UISubTable :-)

                    • 7. Re: export to pdf or excel from rich:dataTable
                      nickarls

                      I'll open a feature JIRA and assign it to you. You can put the code in org.jboss.seam.excel.export.kitchensink. ;-)

                      • 8. Re: export to pdf or excel from rich:dataTable

                        Also please try without the ajax-stuff :-)

                        • 9. Re: export to pdf or excel from rich:dataTable

                          I have just tried something similar to what you have above, and it works. If you see any immediate differences, please post them.



                          xhtml


                          
                               <h:form id="excelExport">
                                    <a4j:commandButton value="Search" reRender="searchResults" action="#{excelTest.search}" />
                                    <a4j:commandButton value="Clear" reRender="searchResults" action="#{excelTest.clear}" />
                          
                          
                                    <a4j:outputPanel id="searchResults">
                          
                                         <rich:dataTable value="#{excelTest.result}" var="person" id="excelTable" columnClasses="left, right">
                                              <rich:column>
                                                   <f:facet name="header">Name</f:facet>
                                                   <h:outputText value="#{person.name} #{person.lastName}"></h:outputText>
                                              </rich:column>
                                              <rich:column>
                                                   <f:facet name="header">Age</f:facet>
                                                   <h:outputText value="#{person.age}"></h:outputText>
                                              </rich:column>
                                         </rich:dataTable>
                                         <h:commandLink value="Export table" action="#{org.jboss.seam.excel.excelExporter.export('excelExport:excelTable')}" />
                          
                                    </a4j:outputPanel>
                               </h:form>
                          




                          javabean


                          @Name("excelTest")
                          @Scope(ScopeType.SESSION)
                          public class ExcelTest
                          {
                          
                             private List<Person> people = new LinkedList<Person>();
                             
                             public List<Person> getPeople()
                             {
                                List<Person> ret = new LinkedList<Person>();
                                for (int i = 0; i < 10; i++)
                                {
                                   ret.add(new Person(i, "Janne_" + i, "Andersson" + i));
                                }
                                return ret;
                          
                             }
                             
                             public List<Person> getResult()
                             {
                                return people;
                             }
                             
                             public void search() {
                                this.people = getPeople();
                             }
                             
                             public void clear() {
                                this.people = new LinkedList<Person>();
                             }
                          }
                          


                          • 10. Re: export to pdf or excel from rich:dataTable
                            infinity2heaven

                            I didn't test it in all browsers. The code works in firefox (3.x) but not in IE 6 or IE 7.
                            Now this really sucks.


                            I'm wondering -- has this anything to do my app being SS: (https) as IE behaves differently for secure sites

                            • 11. Re: export to pdf or excel from rich:dataTable
                              nickarls

                              When you get the 404, is the URL http:// or https://?


                              If http://, what happens if you manually change it to https:// in the browser?

                              • 12. Re: export to pdf or excel from rich:dataTable
                                infinity2heaven

                                I dont see any relevance to your questions and the problem in hand. Perhaps you could suggest what could probably be wrong, since you wrote the code.


                                As for my webapp, I've restricted access to http (even if user access http, port 8080), it redirects to https, port 8443

                                • 13. Re: export to pdf or excel from rich:dataTable
                                  infinity2heaven

                                  AS mentioned earlier, the code does work in firefox. I think you have an incredible component being developed for Seam 2.1. Just need to get the fine details sorted out with browser compatibilities

                                  • 14. Re: export to pdf or excel from rich:dataTable
                                    nickarls

                                    The generated excel data is presented by a redirect to a DocumentStore (same one which is used by pdf generation). I'm trying to determine if something goes wrong in the redirect.

                                    1 2 3 4 Previous Next