-1

i am having a button on clicking this i want to generate a exl file having all data values which i have in a table comming from databse..please help me

Sunil Rawat
  • 617
  • 7
  • 34
  • You have 15 (!) questions with answers and not one have you accepted. Please respect the people who take time out of their busy lives to help people like you. – Chris Pratt Jan 31 '12 at 17:44

3 Answers3

0

Have a look at this PEAR package:

Spreadsheet_Excel_Writer

In case you have knowledge of windows technology, have a look at PHP's COM libary:

http://php.net/manual/de/book.com.php

SteAp
  • 10,824
  • 8
  • 48
  • 83
  • S_E_W is pretty much dead and only supports BIFF 5.0, which is Excel '92 or something. PHPExcel is preferred as it goes up to Excel '07 and supports the new file formats plus can read/write excel files, not just write. – Marc B Apr 28 '11 at 21:08
  • BIFF 5 was introduced with Excel 95, BIFF 8 with Excel 98 and carried through to Excel 2003. The latter introduced the short-lived Excel 2003 SpreadsheetML XML format. Excel 2007 and Excel 2010 both use the Office Open XML format. PHPExcel can read all of these, but can't (yet) write Excel 2003 SpreadsheetML XML, although it's capable of writing all the others. – Mark Baker Apr 28 '11 at 21:15
0

Use a library such as PHPExcel, or one of the alternatives to PHPExcel listed in this thread

EDIT

The answer to this question demonstrates how to do what you're asking: reading data from a database and writing it to Excel

Community
  • 1
  • 1
Mark Baker
  • 199,760
  • 28
  • 325
  • 373
  • i mean i am having a table which contaning all field fatched data from database.like firstName,LastName.etc.now onclicking a button i want to generate a exl file from this table having all field from this table with data. – Sunil Rawat Apr 28 '11 at 21:02
  • Sorry, I thought the answer I'd given to the similar linked question http://stackoverflow.com/questions/4748067/problem-with-phpexcel with it's working code did what you're asking for... all you had to do was use your own SELECT statement. Can you explain exactly what you're having problems with? – Mark Baker Apr 28 '11 at 21:10
0

If you just want some simpel columns & rows without any special design



header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"export.csv\"");

$data.="col1, col2 ... from your database";
echo $data; 


You can import csv into excel.

Fredrik
  • 1,214
  • 11
  • 14
  • If you choose this CSV option, then look at using PHP's built-in fputcsv() function rather than generating each csv line manually – Mark Baker Apr 28 '11 at 20:59