Welcome Guest, Not a member yet? Register   Sign In
.xls suffix on controller function to make excel file?

I know you can take a HTML table and change the extension to .xls to make it pop up as an xls file but I am trying to utilize this with code igniter MVC.

I have a form on one of my pages that takes the table from that page and dumps it into a function/view to put it out as a .xls page.

my URL ends up being something like this. www.siteurl.com/index.php/report/excel but when I add .xls onto it I get a 404.

It may be asking too much for CodeIgniter to accept www.siteurl.com/index.php/report/excel.xls instead of www.siteurl.com/index.php/report/excel.html

If anyone has any ideas or solutions for this I could really use the help.

[eluser]Ivan A. Zenteno[/eluser]
Maybe if you try setting the headers, could be work.


You can probably try something like above and "excel.html" might be passed to index method inside your report controller. Also, you need to consider setting the Content-type header to something that triggers excel

Thanks for the direction on setting the MIME type

I ended up using the PHP header() method like so

header('Content-type: application/vnd.ms-excel');

header('Content-Disposition: attachment; filename="report.xls"');

I don't have the .xls on the url but all I wanted was for the link to make an excel file out of the current document anyway.

Thanks for the help!

With a bit of .htaccess (ReWrite rule) you can get the .xls working too.

Theme © iAndrew 2016 - Forum software by © MyBB