•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,504 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,681 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1453 | Replies: 4
![]() |
•
•
Join Date: Jun 2005
Posts: 85
Reputation:
Rep Power: 4
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.
<?
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.
•
•
Join Date: Aug 2005
Location: somewhere in time
Posts: 71
Reputation:
Rep Power: 4
Solved Threads: 3
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).
•
•
Join Date: Aug 2005
Location: somewhere in time
Posts: 71
Reputation:
Rep Power: 4
Solved Threads: 3
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: 85
Reputation:
Rep Power: 4
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?
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
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


Linear Mode