5 Replies Latest reply on Feb 6, 2007 11:11 PM by norman.richards

    .csv

    tony.herstell1

      Is there an easy way to produce a .csv from a DataSet for download?

      We have iText for .PDF, and even the new mail component.

      ?

        • 1. Re: .csv

          I don't see why you couldn't do that with a facelets template.

          • 2. Re: .csv
            pmuir

            There might be some issues with altering the content type and file extension I guess - ask on the facelets list about this (they are very helpful), but writing out the data should be as easy as:

            <ui:composition ...>
             <ui:repeat value="#{list}" var="row">
             #{row.a},#{row.b},#{row.c}
             </ui:repeat>
            </ui:composition>


            • 3. Re: .csv
              stu2

              Writing out csv files you also have to consider escaping values within which may contain commas.

              It's probably easier just to use a library specifically for csv generation, like http://www.csvreader.com/

              • 4. Re: .csv
                tony.herstell1

                Thanks for the replies.
                I meant for something like a excel sheet icon and you click it to get a save'as dialog box.
                You then Stream down your csv file for the John to save to their hard disk.
                All this info is useful however.

                • 5. Re: .csv

                  It sounds like you might want an EL function or even a component to escape things the way you like. If you think this has general appeal, I strongly encourage you to put something together and make it available. You should be able to make it a one JAR add-on that someone can plop into a seam app and use. (I'd really like to see even more community supported libraries like this in the future)