码迷,mamicode.com
首页 > Web开发 > 详细

php生成excel或php生成csv

时间:2015-01-22 15:14:50      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

一、php生成excel

使用phpexcel类文件生成

 

二、php生成csv

<?php
$action ="make";
if ($action==‘make‘){
$fp = fopen("demo_csv.csv","a"); //打开csv文件,如果不存在则创建
$title = array("First_Name","Last_Name","Contact_Email","Telephone"); //第一行数据

$data_1 = array("42343","423432","4234","4234");
$data_2 = array("4234","Last_Name","Contact_Email","Telephone");

$title = implode(",",$title); //用 ‘ 分割成字符串
$data_1 = implode(",",$data_1); // 用 ‘ 分割成字符串
$data_2 = implode(",",$data_2); // 用 ‘ 分割成字符串

$data_str =$title."\r\n".$data_1."\r\n".$data_2."\r\n"; //加入换行符
fwrite($fp,$data_str); // 写入数据
fclose($fp); //关闭文件句柄
echo "生成成功";
}
echo "<br>";
echo "<a href=‘?action=make‘>生成csv文件</a>";
?>

php生成excel或php生成csv

标签:

原文地址:http://www.cnblogs.com/hechunhua/p/4241534.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!