Dharmender Posted January 11, 2013 Share Posted January 11, 2013 I have generated HTML table from Mysql data using PHP. I want to export this table to Excel. I have 'googled' a lot but not satisfied with it. Quote Link to comment https://forums.phpfreaks.com/topic/273004-export-html-table-to-excel-using-php/ Share on other sites More sharing options...
Christian F. Posted January 11, 2013 Share Posted January 11, 2013 Easiest option is to save it as a CSV file, and then import it into Excel. Quote Link to comment https://forums.phpfreaks.com/topic/273004-export-html-table-to-excel-using-php/#findComment-1404921 Share on other sites More sharing options...
Dharmender Posted January 11, 2013 Author Share Posted January 11, 2013 Easiest option is to save it as a CSV file, and then import it into Excel. 1. How can we save it as csv. 2. Why not directly into .xls format Quote Link to comment https://forums.phpfreaks.com/topic/273004-export-html-table-to-excel-using-php/#findComment-1404923 Share on other sites More sharing options...
Christian F. Posted January 11, 2013 Share Posted January 11, 2013 fputcsv () Because this is a proprietary binary format. Only Microsoft knows for sure how it's defined, and it changes for every single Excel version released.This causes many problems, one of them being that any other implementation of this (which is not directly supported by MS) is actually of dubious legal nature depending upon which country you're in. Quote Link to comment https://forums.phpfreaks.com/topic/273004-export-html-table-to-excel-using-php/#findComment-1404929 Share on other sites More sharing options...
Barand Posted January 11, 2013 Share Posted January 11, 2013 You can open an html file in Excel. Just save the page you've already created. Quote Link to comment https://forums.phpfreaks.com/topic/273004-export-html-table-to-excel-using-php/#findComment-1404940 Share on other sites More sharing options...
Muddy_Funster Posted January 11, 2013 Share Posted January 11, 2013 (edited) you can pretend a page is an exel file by manipulating the header. I don't know how it will translate an html table but using header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=yourFileName.xls"); header("Pragma: no-cache"); header("Expires: 0"); will force the browser to treat the page as an exel file download. Edited January 11, 2013 by Muddy_Funster Quote Link to comment https://forums.phpfreaks.com/topic/273004-export-html-table-to-excel-using-php/#findComment-1404942 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.