Search code examples
phpcodeigniterexport-to-excel

How to save html table in Excel


I have been trying to save html data in excel format(export to excel functionality basically) in PHP. I achieved that by changing header to

                header("Content-type: application/vnd.ms-excel");
                header("Content-Disposition: attachment; filename=$filename");
                header("Pragma: no-cache");
                header("Expires: 0");

But on opening the file, it shows a warning for above excel 2003 applications. So can I save the excel in 2008 or 2010 format just by modifying the header or do I have to go for other frameworks providing this feature like "PHPExcel" or something. And yes, I am using CodeIgniter for my website

Thanks in advance.


Solution

  • You need to use some libraries to generate Excel tables.

    Standart HTML output is not converted automatically to the specified format if you only set the Content-Type you want.