Skip to main content
Participant
February 19, 2010
Answered

Excel issue

  • February 19, 2010
  • 1 reply
  • 402 views

Does anyone know if it is possible to format the Excel spreadsheet (dynamically created using ColdFusion and pulling from a MySQL database) to have the Excel file automatically set to landscape, rather than portrait for printing. My client wants that Excel spreadsheet formatted for him. I have the borders and colors and headers set, but I'm told they've seen this done before, so I was hoping someone could tell me how, or point me in the right direction. I've done a google search, but can't find anything about this. The only way that I can imagine it could be done, is if the data is being put into an Excel file that is acting as a template, with all the features set in advance, but I don't know if that's possible using ColdFusion, nor have I ever seen it done. Any help is greatly appreciated.

    This topic has been closed for replies.
    Correct answer

    you can save an existing excel file to a .xml file and wrap it with

    <cfsavecontent variable="strXmlData">

      <cfsavecontent variable="strXmlData">

          <cfoutput>

          <!--- Excel that was converted into an xml here --->

          </cfoutput>

          </cfsavecontent>
          <cfheader   name="content-disposition"  value="attachment; filename=franchisee.xml"      />
          <cfcontent      type="application/msexcel"      variable="#ToBinary( ToBase64( strXmlData.Trim().ReplaceAll( '> \s+', '>' ).ReplaceAll( '\s+<', '<' ) ) )#"      />

    Or you can check out POI Utility by Ben Nadel.

    1 reply

    Correct answer
    February 19, 2010

    you can save an existing excel file to a .xml file and wrap it with

    <cfsavecontent variable="strXmlData">

      <cfsavecontent variable="strXmlData">

          <cfoutput>

          <!--- Excel that was converted into an xml here --->

          </cfoutput>

          </cfsavecontent>
          <cfheader   name="content-disposition"  value="attachment; filename=franchisee.xml"      />
          <cfcontent      type="application/msexcel"      variable="#ToBinary( ToBase64( strXmlData.Trim().ReplaceAll( '> \s+', '>' ).ReplaceAll( '\s+<', '<' ) ) )#"      />

    Or you can check out POI Utility by Ben Nadel.

    annkroiseAuthor
    Participant
    February 19, 2010

    Thanks for quick reply