| | |
php file export issue
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 92
Reputation:
Solved Threads: 0
I have a simple php file for example:
What I want to do is export php result and save it in excel file. If I run this from web browser like IE,firefox, I have no problem to generate excel file on my local machine.
However I want to run this from command line at background, instead of web browser, now if I open command prompt box and run it, it just print result "test" on command box, there is no export file generated.
Why??? how can I fix this issue?
Any advice will be appreciated.
PHP Syntax (Toggle Plain Text)
<? header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=file123.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "test"; ?>
What I want to do is export php result and save it in excel file. If I run this from web browser like IE,firefox, I have no problem to generate excel file on my local machine.
However I want to run this from command line at background, instead of web browser, now if I open command prompt box and run it, it just print result "test" on command box, there is no export file generated.
Why??? how can I fix this issue?
Any advice will be appreciated.
It looks like your last line is wrong. Also, try this version of the first line. This is what I use:
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=extraction.xls");
header("Pragma: no-cache");
header("Expires: 0");
print $data;
$data needs to hold the tab delimited text file that you create. Your line just tells the routine to print the string "test". You are not passing any data.
You have to format the data. Separate your fields with chr(9) and end each line with chr(9).
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=extraction.xls");
header("Pragma: no-cache");
header("Expires: 0");
print $data;
$data needs to hold the tab delimited text file that you create. Your line just tells the routine to print the string "test". You are not passing any data.
You have to format the data. Separate your fields with chr(9) and end each line with chr(9).
Spreadsheets are for tabular data. How do you plan to break a web page up into cells? Are you talking about data that you are displaying on a PHP page?
I'm not sure how you would do this from a command line.
I'm not sure how you would do this from a command line.
•
•
Join Date: Jun 2005
Posts: 92
Reputation:
Solved Threads: 0
The php page contains table that display dynamic data retrieved from mysql database, I have no problem to display this table on web browser and convert it to excel file, by manually.
Now I need to set cronjob to run this php script at backend to retrieve data from mysql DB and generate excel file in weekly basis, I got stuck here.
Any idea?
Now I need to set cronjob to run this php script at backend to retrieve data from mysql DB and generate excel file in weekly basis, I got stuck here.
Any idea?
![]() |
Similar Threads
- Calling a PHP file from a javascript code (JavaScript / DHTML / AJAX)
- Need help with changing the index.php file (Existing Scripts)
- Can we execute command line cmds from a php file?? (PHP)
- NEW PDF File creation issue using PHP (PHP)
- PHP mail function issue (PHP)
- PHP file calling html control names (PHP)
- PHP5x,Apache2.2 : Apache not reading php file (PHP)
- PHP file displaying wrongly ??? (PHP)
- Get the name of the current php file (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP problem!
- Next Thread: Hyerlink from Mysql
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken buttons cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source sp space speed sql subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web websphere white xml youtube





