Maybe You ve better look at this: http://phpexcel.codeplex.com/
http://www.easyxls.com/“rel=“nofollow”http://www.easyxls.com/
另一trick是拯救您的数据,将其作为CSV文档:。
最新资料:
无法将数据直接输入Excel文档,而是作为CSV保存。 颁布这一法典:
<?php
$data = array( array("firstname" => "Mary", "lastname" => "Johnson", "age" => 25),
array("firstname" => "Amanda", "lastname" => "Miller", "age" => 18),
array("firstname" => "James", "lastname" => "Brown", "age" => 31),
array("firstname" => "Patricia", "lastname" => "Williams", "age" => 7),
array("firstname" => "Michael", "lastname" => "Davis", "age" => 43),
array("firstname" => "Sarah", "lastname" => "Miller", "age" => 24),
array("firstname" => "Patrick", "lastname" => "Miller", "age" => 27) );
# filename for download
$filename = "website_data_" . date( Ymd ) . ".xls";
header("Content-Disposition: attachment; filename="$filename"");
header("Content-Type: application/vnd.ms-excel");
$flag = false;
foreach($data as $row)
{
if(!$flag)
{ # display field/column names as first row echo
implode(" ", array_keys($row)) . "
"; $flag = true;
}
array_walk($row, cleanData );
print implode(" ", array_values($row)) . "
";
}
function cleanData(&$str)
{
$str = preg_replace("/ /", "\t", $str);
$str = preg_replace("/
?
/", "\n", $str);
if(strstr($str, " ))
$str = " . str_replace( " , "" , $str) . " ;
}
?>
关于从进口到岸价的排序问题,你可以读到贵国的html。 php,除掉所有不必要的标签,使每一方或对口单位都告终,然后将贵方的价值观纳入一个整体:
<?php
$htmldata = "";
$htmldata .= "<html>";
$htmldata .= "<body>";
$htmldata .= "<tr>";
$htmldata .= "<th>header1</th>";
$htmldata .= "<th>header2</th>";
$htmldata .= "<th>header3</th>";
$htmldata .= "<th>header4</th>";
$htmldata .= "</tr>";
$htmldata .= "<tr>";
$htmldata .= "<td>data1</td>";
$htmldata .= "<td>data2</td>";
$htmldata .= "<td>data3</td>";
$htmldata .= "<td>data4</td>";
$htmldata .= "</tr>";
$htmldata .= "</body>";
$htmldata .= "</html>";
//Remove the unecessary tags like <html>, </html>, <body>, </body>, <th>, </th>, <td>, </td>
$searchfor = array("<html>", "</html>", "<body>", "</body>", "<tr>", "</tr>", "<th>", "</th>", "<td>", "</td>");
$replacewith = array("", "", "", "", "", "", "", "**SEPERATOR**", "", "**SEPERATOR**"); // Replace </th> & </td> with **SEPERATOR** text
$htmldata = str_replace($searchfor, $replacewith, $htmldata);
$values = explode("**SEPERATOR**", $htmldata); ;
print_r($values);
?>
阵列的头4项价值包含你的头盔价值。 希望有助于......