1 2 Previous Next 20 Replies Latest reply on Sep 29, 2008 3:10 AM by mdesignz

    Specifying Excel Filename

    mdesignz

      Hello,
      I'm using the 1.0 version of jboss-seam-excel to generate Excel spreadsheets from my application.  I invoke it using:


      renderer.render(testSheet.xhtml)
      When it downloads from the browser, it has a filename of testSheet.xls.   Is there a way I can specify a different name?  I didn't notice anything in the docs that would allow me to specify a filename in one of the Excel tags.


      Thanks.

        • 1. Re: Specifying Excel Filename

          Nope, there isn't (except for renaming your xhtml). File a JIRA :)

          • 2. Re: Specifying Excel Filename
            nickarls

            I added a filename attribute to e:workbook which is passed into the DocumentData filename. I'll have to test it before committing it, though ;-)

            • 3. Re: Specifying Excel Filename

              Document it well. If a developer has a document store servlet that matches *.xls, but enters filename=myOwnThing.doc, the file won't be accessible.

              • 4. Re: Specifying Excel Filename
                mdesignz

                That's great!  Thanks.  Unfortunately, until I can get resolution to https://jira.jboss.org/jira/browse/JBSEAM-3450  I won't be able to use it.

                • 5. Re: Specifying Excel Filename

                  Robert: Does the excel/mail examples that comes with Seam work?

                  • 6. Re: Specifying Excel Filename
                    mdesignz

                    I just tried the Excel example, and it works perfectly.   I'm beginning to think that something strange may be going on because I'm using Maven2 to build my project.  I'm grasping for answers if you haven't noticed.   Perhaps something is being brought in as a dependency that shouldn't.  I'll check the exploded EAR to see if I notice anything.   I haven't looked at the Excel source example, but I'll try to emulate it exactly.  Once again, thanks for all the replies and support.
                    -robert.


                    • 7. Re: Specifying Excel Filename
                      mdesignz

                      I slightly modified the excel example.  I added this to ExcelTest:


                      @In
                      private Renderer renderer;


                         public void renderTest()
                         {
                            System.out.println(Getting ready to render file);
                            renderer.render(repeat.xhtml);
                            System.out.println(Back from render);
                         }


                      and then added this to the home.xhtml



                             <h:outputLink action="#{excelTest.renderTest}">
                                      <h:outputText>Try to render it</h:outputText>
                              </h:outputLink>



                             



                      Deployed it to 4.2.2.GA and it doesn't throw an exception, but it also doesn't render the Excel sheet.
                      I know it processes the .xhtml file because if I drop one of my .xhtml files into the example, it complains about not resolving some of the components, but it does NOT throw an exception.  This is very odd.  I'm still going to check if something is being included that shouldn't be from the Maven dependencies.


                      • 8. Re: Specifying Excel Filename

                        I'll have a look at it today. If you haven't changed anything else in the example, it should work fine.

                        • 9. Re: Specifying Excel Filename
                          mdesignz

                          Well, here's the good news.  I scraped all of my POMs to build my project, and grabbed the example that Andreas Eriksson (http://iamandreas.blogspot.com) posted, and rebuilt.  Now, the application doesn't throw an exception during the render, but it doesn't produce any output, so it appears to be behaving like the example.  I'll update the JIRA I created, since it's now a new issue.   Once again, thanks for everyone's help.
                          -robert.


                          • 10. Re: Specifying Excel Filename

                            1. outputLink can't have an action. I used a commandLink instead (nested in a h:form)

                            2. renderer.render(repeat.xhtml); is wrong. shuold be renderer.render(/repeat.xhtml);



                            Changing accordingly, it works fine.

                            • 11. Re: Specifying Excel Filename
                              mdesignz

                              Sorry about the outputLink reference.  I also had it as a commandButton within the form, and then added the commandLink within the form.  I modified the render parameter with and without the forward slash.  I still get nothing rendered.  I'm doing this under Mac OS X, but I doubt that's the issue.  I'll try the latest snapshot to see if that matters.  Very weird.

                              • 12. Re: Specifying Excel Filename
                                nickarls

                                Tried the currently not that well documented experimental feature of setting exportKey=something on workbook, rendering, and then checking if a DocumentData object has appeared in the event context under the something key?

                                • 13. Re: Specifying Excel Filename
                                  mdesignz

                                  This is very odd.  Downloaded a new JBoss AS 4.2.2.GA, latest Seam 2.1 Snapshot.  Made the above changes to ExcelTest.java and home.xhtml.  Ran ant, started the server, clicked on the link to invoke renderTest().  I have println statements that indicate renderTest() is getting invoked.  The render method gets called without error.  I put a println in the getRepeat() and it's getting called, yet nothing gets generated.  If I click on the other link that invokes the repeat.xhtml file directly, it works just fine.  Mac OS X, with latest Firefox and Safari.  That can't be it...can it?

                                  • 14. Re: Specifying Excel Filename

                                    I might misunderstand, but too me, everything works fine for you. You won't get anything back calling renderer.render, if thats what you think. Renderer.render renders the document, it doesn't send it to the user. For that top work, you need to go to repeat.seam, or send the created excel file to the user yourself (accessible using an exportKey).


                                    To be perfectly clear, the following code shouldn't send an the excel file to the user:


                                    public void renderTest() { System.out.println("Getting ready to render file"); renderer.render("repeat.xhtml"); System.out.println("Back from render"); } 



                                    It will just creata an excel file.

                                    1 2 Previous Next