exportar a excel

jorge orozco
26 de Julio del 2005
necsito exportar datos a excel y graficar o sacar graficos estadisticos

Erzengel
26 de Julio del 2005
Tengo el mismo problema y soy incapaz de dar con la solucion por más que miro por mil sitios.

tgp
26 de Julio del 2005
exportar a excel facil :) con este codigo


//codigo modificado por tgp
define(db_host, "localhost");
define(db_user, "user");
define(db_pass, "pass");
define(db_link, mysql_connect(db_host,db_user,db_pass));
define(db_name, "DB");
mysql_select_db(db_name);
/********************************************
Write the query, call it, and find the number of fields
/********************************************/
$db = "DB";
$table = "tabla";
$select = "SELECT * FROM tabla";
$export = mysql_query($select);
$count = mysql_num_fields($export);
/********************************************
Extract field names and write them to the $header
variable
/********************************************/
for ($i = 0; $i < $count; $i++) {
$header .= mysql_field_name($export, $i)."t";
}
/********************************************
Extract all data, format it, and assign to the $data
variable
/********************************************/
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);
/********************************************
Set the default message for zero records
/********************************************/
if ($data == "") {
$data = "n(0) Records Found!n";
}
/********************************************
Set the automatic downloadn section
/********************************************/
//header("Content-type: application/octet-stream");
header("Content-Type: application/force-download; name="$db - $table"");
//header("Content-Disposition: attachment; filename=archivodeexcel.xls");
header("Content-Disposition: attachment; filename=$db - $table.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$headern$data";
echo "Se exporto correctamente!!";


ahora graficar.... saber como :S