amolv Posted May 17, 2011 Share Posted May 17, 2011 Hi all, I wanted to generate report in excel from data in mysql on button click, so what are the ways we can use to do that? Quote Link to comment Share on other sites More sharing options...
phppaper Posted May 17, 2011 Share Posted May 17, 2011 This is an example http://www.daniweb.com/web-development/php/threads/124300 Quote Link to comment Share on other sites More sharing options...
amolv Posted May 17, 2011 Author Share Posted May 17, 2011 OK thank you phppaper, $sql = "SELECT * FROM tablename"; $rec = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_row($rec); $filename ="excelreport.xls"; $contents = $row[0]." \t ".$row[1]." \t ".$row[2]." \t \n"; header('Content-type: application/ms-excel'); header('Content-Disposition: attachment; filename='.$filename); echo $contents; its giving me what i am looking for since morning today, thank you once again. let me see formatting of excel sheet, and pdf output Quote Link to comment Share on other sites More sharing options...
amolv Posted May 17, 2011 Author Share Posted May 17, 2011 now for pdf , $sql = "SELECT * FROM table"; $rec = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_row($rec); $filename ="salereport.pdf"; $contents = $row[0]." \t ".$row[1]." \t ".$row[2]." \t \n"; header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename='.$filename); echo $contents; the same code for pdf, its creating pdf file with decode error to open. How to solve this? Quote Link to comment Share on other sites More sharing options...
amolv Posted May 17, 2011 Author Share Posted May 17, 2011 need pdf library for pdf output.....! Quote Link to comment 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.