Davey Gale
02-23-2005, 10:09 AM
Hi there
I have created an Excel workbook that i wish to be accessed from my website online. (the workbook is on my server space). Currently the link i have set up directly points to the Excel file. When I click the link it opens up the Excel worksheet within a Internet Browser. I dont want this, i want the user to be given a prompt which asks whether they want to open or save the document, if they click open i want it to open in Excel itself and not a browser window.
Can i setup a php script that when clicked it brings up a menu which asks whether you want to open, save or cancel. (as opposed to directly linking to the file). When you click open i want Excel itself to open up on the PC - not through a browser.
The following unrelated script I use causes the Excel program to open and display the contents of 1 of my mysql databases:
<?php
define(db_host, "localhost");
define(db_user, "test");
define(db_pass, "test");
define(db_link, mysql_connect(db_host,db_user,db_pass));
define(db_name, "test");
mysql_select_db(db_name);
$select = "SELECT * FROM test";
$export = mysql_query($select);
$fields = mysql_num_fields($export);
for ($i = 0; $i < $fields; $i++) {
$header .= mysql_field_name($export, $i) . "\t";
}
while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = "\t";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r","",$data);
if ($data == "") {
$data = "\n(0) Records Found!\n";
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=extraction.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
?>
Can i steal something from this which will give me the same effect? I just want the file to force the PC to load Excel independently - not have it load excel within an internet browser.
Is this possible? Any input would be brilliant.
I have created an Excel workbook that i wish to be accessed from my website online. (the workbook is on my server space). Currently the link i have set up directly points to the Excel file. When I click the link it opens up the Excel worksheet within a Internet Browser. I dont want this, i want the user to be given a prompt which asks whether they want to open or save the document, if they click open i want it to open in Excel itself and not a browser window.
Can i setup a php script that when clicked it brings up a menu which asks whether you want to open, save or cancel. (as opposed to directly linking to the file). When you click open i want Excel itself to open up on the PC - not through a browser.
The following unrelated script I use causes the Excel program to open and display the contents of 1 of my mysql databases:
<?php
define(db_host, "localhost");
define(db_user, "test");
define(db_pass, "test");
define(db_link, mysql_connect(db_host,db_user,db_pass));
define(db_name, "test");
mysql_select_db(db_name);
$select = "SELECT * FROM test";
$export = mysql_query($select);
$fields = mysql_num_fields($export);
for ($i = 0; $i < $fields; $i++) {
$header .= mysql_field_name($export, $i) . "\t";
}
while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = "\t";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r","",$data);
if ($data == "") {
$data = "\n(0) Records Found!\n";
}
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=extraction.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$header\n$data";
?>
Can i steal something from this which will give me the same effect? I just want the file to force the PC to load Excel independently - not have it load excel within an internet browser.
Is this possible? Any input would be brilliant.
