| | |
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 |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions simple sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





