| | |
How to create an excel spreadsheet?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
We have all wanted data to be transfered to excel at one stage or another. I would like to know how people have done it and come to a general consensis on how it should be done. I usually use fopen or simple echo statement and declaring it as .xls or .csv when required. I have found a new error which brings up a NON EXCEL format and a SYLK error (due to me using sessions in the same file I am downloading, which I dont know why it matters). But if I wish to remove both errors as it does not look professional. Also I would like to know the offical content type for both excel formats (.xls and .xlsx). Add your comments and self code so we can get a general consensis!!!
My code:
Regards, X
My code:
php Syntax (Toggle Plain Text)
session_start(); $filename = "test.xls"; $ABC = $_SESSION['A']; // Yes a valid session from previous page $line_1 = "A" . "\t" . "B" . "\t" . "C"; $line_2 = "1" . "\t" . "2" . "\t" . "3"; $line_3 = "HELLO " . $ABC; $data = $line_1 . "\n" . $line_2 . "\n" . $line_3; session_destroy(); // What I find a mystery is what is the OFFICAL content type for excel? header("Content-Type: application/x-msexcel"); header("Content-Disposition: attachment; filename=" . $filename); echo $data;
Regards, X
Last edited by OmniX; Sep 18th, 2009 at 2:14 am.
"You never stop learning." - OmniX
![]() |
Similar Threads
- Struggling on reading excel spreadsheet (C#)
- Mail merge: Excel spreadsheet data to MS Word doc (Windows Software)
- Unable to create an excel file in VB.net (VB.NET)
- Excel spreadsheet columns need to be resized on open - everytime (Windows Software)
- How to: Excel Spreadsheet online?? (HTML and CSS)
- turning excel spreadsheet into a software application (IT Professionals' Lounge)
- Saving Excel Spreadsheet using ADO.net gives inconsistent results (C#)
- Excel Spreadsheet as HTML (HTML and CSS)
Other Threads in the PHP Forum
- Previous Thread: MY PHP MySQL Function keeps returning error message: "Database Query Failed"
- Next Thread: securing form data
| Thread Tools | Search this Thread |
advanced apache api array beginner binary broken cakephp check checkbox class cms code cookies cron curl database date datepart display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google head href htaccess html if...loop image include includingmysecondfileinthechain insert ip javascript job joomla jquery key library limit link login mail menu mlm multiple mysql oop password paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search server sessions smarty sms sorting source space sql startup stored syntax system table traffic tutorial unicode update upload url validator variable video web youtube zend





