I need to display data from MySQL to Excel format. I looked at several excel classes, but they are missing three things that I need.

  1. To be able to output a cell larger than 255 characters.
  2. Be able to keep line breaks in cells.
  3. be able to format the cell widths

I am currently using a tab delimited set up with excel http headers, but I can not format the cell widths. Anyone have any ideas (Please don't refer me to Biffwriter)?

    6 days later

    Someone did suggest to me to try using the excel's xml format of saved spreadsheet as a html file. Here is what I have. Problem is that have yet to get this to open up on a MAC. It just opens as a regular html page. Any suggestions??

    <?
    //This line will stream the file to the user rather than spray it across the screen
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=leg_tracker.xls" );
    header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
    header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
    header("Pragma: public");
    ?>
    <html xmlns:o="urn:schemas-microsoft-com:office:office" 
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns="http://www.w3.org/TR/REC-html40">
    
    <head>
    
    <!--[if gte mso 9]><xml>
     <o:DocumentProperties>
      <o:Subject>Legislation Tracker Excel Report</o:Subject>
      <o:Author></o:Author>
      <o:Keywords>None</o:Keywords>
      <o:Description>This report was generating for the purpose of displaying legislation bills.</o:Description>
      <o:LastAuthor></o:LastAuthor>
      <o:Created>2003-10-16T18:59:01Z</o:Created>
      <o:LastSaved>2003-10-16T19:14:31Z</o:LastSaved>
      <o:Category></o:Category>
      <o:Manager></o:Manager>
      <o:Company></o:Company>
      <o:Version>10.4219</o:Version>
     </o:DocumentProperties>
     <o:OfficeDocumentSettings>
      <o:DownloadComponents/>
      <o:LocationOfComponents HRef="/"/>
     </o:OfficeDocumentSettings>
    </xml><![endif]-->
    <style>
    <!--table
    	{mso-displayed-decimal-separator:"\.";
    	mso-displayed-thousand-separator:"\,";}
    @page
    	{margin:1.0in .75in 1.0in .75in;
    	mso-header-margin:.5in;
    	mso-footer-margin:.5in;}
    tr
    	{mso-height-source:auto;}
    col
    	{mso-width-source:auto;}
    br
    	{mso-data-placement:same-cell;}
    .style0
    	{mso-number-format:General;
    	text-align:general;
    	vertical-align:bottom;
    	white-space:nowrap;
    	mso-rotate:0;
    	mso-background-source:auto;
    	mso-pattern:auto;
    	color:windowtext;
    	font-size:10.0pt;
    	font-weight:400;
    	font-style:normal;
    	text-decoration:none;
    	font-family:Arial;
    	mso-generic-font-family:auto;
    	mso-font-charset:0;
    	border:none;
    	mso-protection:locked visible;
    	mso-style-name:Normal;
    	mso-style-id:0;}
    td
    	{mso-style-parent:style0;
    	padding-top:1px;
    	padding-right:1px;
    	padding-left:1px;
    	mso-ignore:padding;
    	color:windowtext;
    	font-size:10.0pt;
    	font-weight:400;
    	font-style:normal;
    	text-decoration:none;
    	font-family:Arial;
    	mso-generic-font-family:auto;
    	mso-font-charset:0;
    	mso-number-format:General;
    	text-align:general;
    	vertical-align:bottom;
    	border:none;
    	mso-background-source:auto;
    	mso-pattern:auto;
    	mso-protection:locked visible;
    	white-space:nowrap;
    	mso-rotate:0;}
    -->
    </style>
    <!--[if gte mso 9]><xml>
     <x:ExcelWorkbook>
      <x:ExcelWorksheets>
       <x:ExcelWorksheet>
        <x:Name>Sheet1</x:Name>
        <x:WorksheetOptions>
    	 <x:Selected/>
         <x:ProtectContents>False</x:ProtectContents>
         <x:ProtectObjects>False</x:ProtectObjects>
         <x:ProtectScenarios>False</x:ProtectScenarios>
        </x:WorksheetOptions>
       </x:ExcelWorksheet>
      </x:ExcelWorksheets>
      <x:WindowHeight>8700</x:WindowHeight>
      <x:WindowWidth>15195</x:WindowWidth>
      <x:WindowTopX>0</x:WindowTopX>
      <x:WindowTopY>90</x:WindowTopY>
      <x:ActiveSheet>1</x:ActiveSheet>
      <x:ProtectStructure>False</x:ProtectStructure>
      <x:ProtectWindows>False</x:ProtectWindows>
     </x:ExcelWorkbook>
    </xml><![endif]-->
    </head>
    
    <body link=blue vlink=purple>
    
    <table x:str border=0 cellpadding=0 cellspacing=0 width=154 style='border-collapse:
    collapse;table-layout:fixed;width:116pt'>
    <col width=90 style='mso-width-source:userset;mso-width-alt:3291;width:68pt'>
     <col width=64 style='width:48pt'>
     <tr height=46 style='mso-height-source:userset;height:34.5pt'>
      <td height=46 width=90 style='height:34.5pt;width:68pt'>This will be a really long sentence to see if the excel will trunacate
      the line. This will be a really long sentence to see if the excel will
      trunacate the line. This will be a really long sentence to see if the excel
      will trunacate the line. This will be a really long sentence to see if the
      excel will trunacate the line. This will be a really long sentence to see if
      the excel will trunacate the line. This will be a really long sentence to see
      if the excel will trunacate the line. This will be a really long sentence to
      see if the excel will trunacate the line. 8888<br><br>
    
      eqwuorth qerht qhetr qihert</td>
      <td width=64 style='width:48pt'>Test 2</td>
     </tr>
     <![if supportMisalignedColumns]>
     <tr height=0 style='display:none'>
      <td width=90 style='width:68pt'></td>
      <td width=64 style='width:48pt'></td>
     </tr>
     <![endif]>
    </table>
    
    </body>
    
    </html>
    
      Write a Reply...