0 Replies Latest reply on Nov 6, 2011 11:10 PM by amarinis.a.marinis.base2services.com

    Excel attachment in email under 2.1.1

    amarinis.a.marinis.base2services.com

      I could not find the right place to put this in. However i found that it may be important enough to post for others incase they have the same issue. In particular, I probably spent a few hours trying to work out a clean workaround.


      If you, like me, are stuck using Seam 2.1.1 or older on one of your apps and do not have the luxury of upgrading, you will find that Excel templates in an email attachment do not work, or atleast did not work for me. A Bug was raised in Seam that was fixed from 2.2.0.GA onwards, so if you can upgrade do so.


      However, having an excel template generated in a Mail attachment always produces an empty attachment in 2.1.1. After hours of playing with this and searching the seam forums I thought I would try the following, and it worked!


      Basically, I wanted this


      <e:workbook >
                              <e:worksheet name="Schedule" value="#{emailScheduleService.getEmployeeSchedule()}" var="#{'booking'}">
                                  <e:column autoSize="true">
                                      <f:facet name="header">
                                          <e:cell value="Schedule" />
                                      </f:facet>
                                      <e:cell value="#{booking.scheduledDate}" />
                                  </e:column>


      but unfortunately, this does not work. So I did this....


      <h:dataTable id="clientSearchResultsTable"
                                              value="#{emailScheduleService.getEmployeeSchedule()}" var="result">
                                              <h:column sortBy="#{result.scheduledDate}">
                                                      <f:facet name="header">Scheduled Time</f:facet>
                                                      <h:outputText value="#{result.scheduledDate}">
                                                              <s:convertDateTime pattern="dd/MM/yyyy hh:mm aaa" />
                                                      </h:outputText>
                                              </h:column>

      and it worked...


      Oh, do not forget to put this segment of code in your m:attachment tag like this

      <m:attachment  fileName="Schedule.xls" contentType="application/vnd.ms-excel">
                     
                      <h:dataTable id="clientSearchResultsTable"
                                              value="#{emailScheduleService.getEmployeeSchedule()}" var="result">
                                              <h:column sortBy="#{result.scheduledDate}">
                                                      <f:facet name="header">Scheduled Time</f:facet>
                                                      <h:outputText value="#{result.scheduledDate}">
                                                              <s:convertDateTime pattern="dd/MM/yyyy hh:mm aaa" />
                                                      </h:outputText>
                                              </h:column>


      Hope this helps others