返回目录:excel表格制作
这属于php的技术;
php可以用PHPExcel直接导出成excel文件;
代码如下:636f70797a64362
require_once("../lib/excelcreator.class.php");
$myxls = new ExcelCreator ("中文Excel");
$aTableHead = '
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Name3</Data></Cell> <Cell><Data ss:Type="String">Surname3</Data></Cell> </Row>';
$aTableBody = '
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">Schwarz3</Data></Cell> <Cell><Data ss:Type="String">Oliver3</Data></Cell> </Row>';
$aTableBottom = '
<Row ss:AutoFitHeight="0">
<Cell><Data ss:Type="String">123</Data></Cell> <Cell><Data ss:Type="String">Peter3</Data></Cell> </Row>';
$workSheet = $myxls->createWorkSheet ( "中文sheet1", $aTableHead, $aTableBody, $aTableBottom );
echo $myxls->createExcel ( $workSheet );
推荐一个简单粗暴的输百出办法,虽然excel会报个错,但度是不影响浏览
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=test_data.xls");
//输出内容如下:
echo "姓名知"."\t";
echo "年龄"."\t";
echo "学历"."\t";
echo "\n";
echo "张三"."\t";
echo "25"."\t";
echo "本科"."\t";
?>
但是这单纯道是导出,再导入的时候就要复杂很多内了
推荐phpExcel插件,这个操作我就不在这里细说了,一句半句真说不容清楚。
\r\n 和 chr(10) . chr(13) 都是可以的,看起来只增加了一个空格的占位符,这是因为没有设置单元格的自动换行属性,也就是说不允许单元格内容换行,所以换行字符显示为空格。
<?php
$file_name = $img[0]['file'];//路径
$type = $img[0]['type'];
$pro_name = 'name';
$file_name=iconv("utf-8","gb2312",$file_name);
$file=$file_name;
ob_end_clean();//清除缓存e79fa5e98193e59b9ee7ad94337
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");;
header("Content-Transfer-Encoding:binary");
header("Content-Length: ". filesize($file));
header('Content-Disposition: attachment; filename="'.$pro_name.date('YmdHis').'.'.$type);
readfile($file);