Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Exporting a database to an excel file should not be difficult since excel can read xhtml.</p> <p>Just output your information as a regular HTML table</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt;title&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;record1&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>and then add these headers to force automatic download and interpretation as an excel file:</p> <pre><code>header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); header ("Content-type: application/x-msexcel"); header ("Content-Disposition: attachment; filename=\"{$yourFileName}\"" ); header ("Content-Description: PHP Generated Data" ); </code></pre> <p>It should work as intended.</p> <p>EDIT: Here's an example of a table to xls with correct XHTML schema:</p> <pre><code>&lt;?php header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); header ("Content-type: application/x-msexcel"); header ("Content-Disposition: attachment; filename=newtest.xls" ); header ("Content-Description: PHP Generated Data" ); ?&gt; &lt;html xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"&gt; &lt;head&gt; &lt;meta name="Excel Workbook"&gt; &lt;meta http-equiv=Content-Type content="text/html; charset=utf-8"&gt; &lt;meta name=ProgId content=Excel.Sheet&gt; &lt;meta name=Generator content="Microsoft Excel 14"&gt; &lt;style&gt; #test { font-style:italic; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;header in bold&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;i&gt;header in italic&lt;/i&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1&lt;/td&gt; &lt;td&gt;&lt;span style="font-weight:bold; font-style:italic"&gt;my data with css styling&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;2&lt;/td&gt; &lt;td&gt;&lt;span id="test"&gt;I'm italic 'cause I can read style&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload