ho scaricato da questo link:
http://www.zend.com/codex.php?id=899&single=1
uno script per esportare in excel il dump dei dati di una tabella
il file viene scaricato correttamente ma presenta degli errorini che secondo me sono dovuti al fatto che alcune celle provengono da dati contenenti degli a capo e sballano tutto il foglio di excel.
non ci caspisco tantissimo ma sicuramente la modifica da fare è qui:
Codice PHP:
//define separator (defines columns in excel & tabs in word)
$sep = "\t"; //tabbed character
//start of printing column names as names of MySQL fields
for ($i = 0; $i < mysql_num_fields($result); $i++) {
echo mysql_field_name($result,$i) . "\t";
}
print("\n");
//end of printing column names
while($row = mysql_fetch_row($result))
{
//set_time_limit(60); // HaRa
$schema_insert = "";
for($j=0; $j<mysql_num_fields($result);$j++)
{
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
elseif ($row[$j] != "")
$schema_insert .= "$row[$j]".$sep;
else
$schema_insert .= "".$sep;
}
$schema_insert = str_replace($sep."$", "", $schema_insert);
//following fix suggested by Josue (thanks, Josue!)
//this corrects output in excel when table fields contain n or r
//these two characters are now replaced with a space
//$schema_insert = preg_replace("/rn|nr|n|r/", " ", $schema_insert);
$schema_insert .= "\t";
print(trim($schema_insert));
print "\n";
}
}
ripeto: alcuni campi nella tab mysql contengono degli a capo, il problema sta li. mi aiutate please?
grazie.