PHP处理excel cvs表格的方法实例介绍

复制代码 代码如下:
<PRE class=php name="code"><?php
$data = array();
//convert a cvs file to an array $data
$handle = fopen("data.csv","r");
while ($curline = fgetcsv($handle, 1000, ",")){
$tmp = array();
$num = count($curline);
for($c=0; $c < $num; $c++){
array_push($tmp, $curline[c]);
}
array_push($data, $tmp);
}
print_r($data);
fclose($handle);
//convert array $data back to a cvs file
$handle = fopen("result.csv","w");
foreach($data as $curline){
if(fputcsv($handle, $curline)==false){
die("cannot write CSV line");
}
}
fclose($handle);
?>
</PRE><BR>
<BR>
<PRE></PRE>

php技术PHP处理excel cvs表格的方法实例介绍,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。