vishak Posted February 19, 2011 Report Share Posted February 19, 2011 My Requirement is to export my database table data into an excel format. What is the easiest way to convert selected table data into excel format using PHP ? Is there a php function or a library or something like that? Quote Link to comment Share on other sites More sharing options...
kraxzy Posted February 19, 2011 Report Share Posted February 19, 2011 The abosulote easiet.. well that would be via phpMyAdmin -> Export -> [Then choose either CVS for excel or excel file] And that should fix it, as it's easier to use that than coding it from scratch that's for sure. Quote Link to comment Share on other sites More sharing options...
vishak Posted February 19, 2011 Author Report Share Posted February 19, 2011 What I meant was from the user's point of view. For the project I am working on, one of my requirements is to save selected data in excel format. The end-user selects the data to be printed or saved. And I need the code for the same. It is not from the admin's point of view. Sorry if I didn't mention it. Quote Link to comment Share on other sites More sharing options...
is_numeric Posted February 28, 2011 Report Share Posted February 28, 2011 (edited) You can do this a number of ways using PHP... Look at fwrite [example]... $f = fopen('/tmp/data.csv', 'a'); //<< in 'a' append mode fwrite($f, 'line of data 1'); //<< you will have to loop through this line fclose($f); // close handle Or using a MYSQL query... [example]... SELECT field1,field2,field3 FROM table INTO OUTFILE '/tmp/data.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' Edited February 28, 2011 by is_numeric Quote Link to comment Share on other sites More sharing options...
vishak Posted February 28, 2011 Author Report Share Posted February 28, 2011 There is a set of PHP classes called PHPExcel for my purpose. But I have difficulty using the same.I think I have some errors in including some extensions. If anybody has used PHPExcel please respond. 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.
Note: Your post will require moderator approval before it will be visible.