SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exporting to excel.

    Hi

    I need HTML tables to be exported to excel.

    header("Content-Type: application/vnd.ms-excel");
    header("Content-Disposition: attachment; filename=CAIMSReport.xls");

    I added the above two lines at the end of the code. I know I am doing something wrong. Can anyone help me with this?

    My code is below. Basically, $excel has html tables. I just need them to export it in excel.



    $excel= '<table width="85%" border="1" cellspacing="1" cellpadding="1">
    <tr>
    <td width="10%">&nbsp;</td>
    <td width="33%">1st Level Support </th>
    <td width="28%">2nd Level Support </th>
    <td width="29%">Escalation</th>
    </tr>
    </table>
    ';

  2. #2
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Phoenix, AZ
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why not just export to .csv??it will still work with excel. the problem with .xls files is that .xls uses a proprietary stylesheet similar to CSS and uses XML..

    If you got this to open in Excel, you'll have to tell me, because i needed to do something similar.

    The only thing I was able to do was a COM object, but it kept screwing my stuff up..

    Anyway, if you don't need special formatting try using
    content-type: text/csv
    Kreative Development
    Infinite Possibilities

  3. #3
    SitePoint Zealot
    Join Date
    May 2006
    Location
    Phoenix, AZ
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PS content headers must be at the top...before anything is echo'd otherwise your code will get screwed up.
    Kreative Development
    Infinite Possibilities

  4. #4
    SitePoint Zealot
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Might take a look here...

    Introducing PEAR::Spreadsheet_Excel_Writer

    "Impossible!" you cry. "Excel uses some proprietary Microsoft file format. This can't be done!"

    Yes, it can. Spreadsheet_Excel_Writer generates the "real thing", complete with Excel functions, formatting and all. No, we're not talking generating comma separated files here, or using the COM extension (or any other extension, for that matter). This is written in pure PHP and will work just as well from a UNIX-based Web server as it does from a Windows-based server -- and there's no need to bug your hosting provider. In short, PEAR::Spreadsheet_Excel_Writer, with additional magic from PEAR::OLE, "understands" Microsofts Excel file formats.
    http://www.sitepoint.com/article/pea...t_excel_writer


    Lite...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •