Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-3948

Excel attachment should be more user-friendly to create

    Details

      Description

      Excel attachments should be easy to create with syntax similar to that of PDF. I would like a syntax like this to work:
      <m:attachment fileName="people.xls"><ui:include src="/mail-xls.xhtml" /> </m:attachment>
      Workaround exists (thanks, Daniel): Define exportKey in <e:workbook> and then look it up from context after rendering excel content, then render mail content:
      FaceletsRenderer.instance().render("/mail-xls.xhtml");
      DocumentData excelData = (DocumentData) Contexts.getEventContext().get("excelKey");
      FaceletsRenderer.instance().render("/mailExcel.xhtml");

      In mail definition the looked up DocumentData has to be referenced in the value property: <m:attachment fileName="people.xls" value="#

      {excelData}

      " contentType="application/vnd.ms-excel"/>

      For testing purposes I attach a template that uses the Person class from the mail example:
      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:e="http://jboss.com/products/seam/excel"
      xmlns:f="http://java.sun.com/jsf/core">

      <e:workbook type="jxl">
      <e:worksheet name="People" value="#

      {people}

      " var="p">
      <e:header>
      <f:facet name="left">
      The date is #date# and the time is #time#
      </f:facet>
      </e:header>
      <e:column style="xls-column-autosize: true">
      <f:facet name="header">
      <e:cell value="First name" style="xls-font: red bold 10 Verdana"/>
      </f:facet>
      <e:cell value="#

      {p.firstname}

      " />
      </e:column>
      <e:column style="xls-column-autosize: true">
      <f:facet name="header">
      <e:cell value="Last name" style="xls-font: red bold 10 Verdana"/>
      </f:facet>
      <e:cell value="#

      {p.lastname}

      " forceType="text"/>
      </e:column>
      <e:column style="xls-column-autosize: true">
      <f:facet name="header">
      <e:cell value="Email" style="xls-font: red bold 10 Verdana"/>
      </f:facet>
      <e:cell value="#

      {p.address}

      "/>
      </e:column>
      </e:worksheet>
      </e:workbook>
      </html>

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                d00roth Daniel Roth
                Reporter:
                Zoltan Tiringer Zoltan Tiringer
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: