title: how to create xlsx files using coldfusion
body: <p>Disclaimer: I am new into coldfusion.
  I am trying to create an Excel 2010 document with images and multiple tabs.
  I have been able to get this to output into XLS, but I cannot get the image into the file.</p>
  
  <p>I have not been able to find a complete example of how to Properly create an XLSx file.
  I would prefer to learn the right way and develop my own bad habits later, rather than just have bad habits.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>&lt;!--- Make CF export to Excel ---&gt;
  &lt;!--- This will create a XLS file ---&gt;
  &lt;!--- &lt;cfheader name="Content-Disposition" value="attachment; filename=#URL.TRNo#_image.xls"&gt;
  &lt;cfcontent type="application/vnd.msexcel"&gt; ---&gt;
  
  &lt;!--- This does not work to create an XLSX file ---&gt;
  &lt;cfheader name="Content-Disposition" value="inline; filename=#URL.TRNo#_image.xlsx"&gt;
  &lt;cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&gt; 
  
  &lt;cfparam name="URL.TRNo" default="AD0310"&gt;
  
  &lt;cfoutput&gt;
      &lt;?xml version="1.0"?&gt;
      &lt;Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"&gt;
          &lt;ss:Styles&gt;
              &lt;ss:Style ss:ID="Default" ss:Name="Normal"&gt;
                  &lt;ss:Font ss:Size="11" ss:FontName="Calibri"/&gt;
              &lt;/ss:Style&gt;
              &lt;ss:Style ss:ID="Left"&gt;
                  &lt;ss:Alignment ss:Horizontal="Left"/&gt;
              &lt;/ss:Style&gt;
              &lt;ss:Style ss:ID="Center"&gt;
                  &lt;ss:Alignment ss:Horizontal="Center"/&gt;
              &lt;/ss:Style&gt;
              &lt;ss:Style ss:ID="Right"&gt;
                  &lt;ss:Alignment ss:Horizontal="Right"/&gt;
              &lt;/ss:Style&gt;
          &lt;/ss:Styles&gt;
  
  
          &lt;Worksheet ss:Name="#URL.TRNo# page 1"&gt;
              &lt;ss:Table ss:DefaultColumnWidth="15" ss:DefaultRowHeight="15"&gt;
                  &lt;Row ss:Height="51"&gt;&lt;!--- Start Row 1 ---&gt;
                      &lt;Cell ss:Index="1" ss:MergeAcross="9"&gt;
                          &lt;Data ss:Type="String"&gt;Final Test Report&lt;/Data&gt;
                      &lt;/Cell&gt;
                      &lt;Cell ss:Index="11" ss:MergeAcross="10" ss:StyleID="Center"&gt;
                          &lt;Data ss:Type="String"&gt;&lt;!--- &lt;img src="http://wwwdev.elmsweb.ford.com/elmsGEN3/SafetyLab/FMVSS/ReportWriter/img/fordLogo_transparent_small.png" height="68" width="181" alt="13"&gt; ---&gt;&lt;/Data&gt;
                      &lt;/Cell&gt;
                      &lt;Cell ss:Index="22" ss:MergeAcross="9" ss:StyleID="Right"&gt;
                          &lt;Data ss:Type="String"&gt;Confidential&lt;/Data&gt;
                      &lt;/Cell&gt;
                  &lt;/Row&gt;&lt;!--- End Row 1 ---&gt;
                  &lt;Row/&gt;&lt;!--- Row 2 Blank ---&gt;
                  &lt;Row&gt;&lt;!--- Start Row 3 ---&gt;
                      &lt;Cell ss:Index="1" ss:MergeAcross="1" ss:StyleID="Right"&gt;
                          &lt;Data ss:Type="String"&gt;To:&lt;/Data&gt;
                      &lt;/Cell&gt;
                      &lt;Cell ss:Index="3" ss:MergeAcross="12"&gt;
                          &lt;Data ss:Type="String"&gt;&lt;/Data&gt;
                      &lt;/Cell&gt;
                      &lt;Cell ss:Index="16" ss:MergeAcross="10" ss:StyleID="Right"&gt;
                          &lt;Data ss:Type="String"&gt;Test Order:&lt;/Data&gt;
                      &lt;/Cell&gt;
                      &lt;Cell ss:Index="27" ss:MergeAcross="4"&gt;
                          &lt;Data ss:Type="String"&gt;#URL.TRNo#&lt;/Data&gt;
                      &lt;/Cell&gt;
                  &lt;/Row&gt;&lt;!--- End Row 3 ---&gt;
              &lt;/ss:Table&gt;
          &lt;/Worksheet&gt;
      &lt;/Workbook&gt;
  &lt;/cfoutput&gt;
  </code></pre>