phpexcel 导出 linux
在本地运行。导出excel都没问题,但是部署到服务器上就没反应了,看了网上类似注销//require_once phpexcel_root . 'phpexcel/shared/zipstreamwrapper.php';也没作用,以下是导出代码,各位大神谢谢给出意见:
//excel导出
function excel(){
require_once './classes/phpexcel.php';
require_once './classes/phpexcel/iofactory.php';
$u = d('clients');
$data=$_session['datas'];
$objphpexcel = new phpexcel();
// set properties
$objphpexcel->getproperties()->setcreator("ctos")
->setlastmodifiedby("ctos")
->settitle("office 2007 xlsx test document")
->setsubject("office 2007 xlsx test document")
->setdescription("test document for office 2007 xlsx, generated using php classes.")
->setkeywords("office 2007 openxml php")
->setcategory("test result file");
//set width
$objphpexcel->getactivesheet()->getcolumndimension('a')->setwidth(8);
$objphpexcel->getactivesheet()->getcolumndimension('b')->setwidth(10);
$objphpexcel->getactivesheet()->getcolumndimension('c')->setwidth(25);
$objphpexcel->getactivesheet()->getcolumndimension('d')->setwidth(12);
$objphpexcel->getactivesheet()->getcolumndimension('e')->setwidth(50);
$objphpexcel->getactivesheet()->getcolumndimension('f')->setwidth(10);
$objphpexcel->getactivesheet()->getcolumndimension('g')->setwidth(12);
$objphpexcel->getactivesheet()->getcolumndimension('h')->setwidth(12);
$objphpexcel->getactivesheet()->getcolumndimension('i')->setwidth(12);
$objphpexcel->getactivesheet()->getcolumndimension('j')->setwidth(30);
//设置行高度
$objphpexcel->getactivesheet()->getrowdimension('1')->setrowheight(22);
$objphpexcel->getactivesheet()->getrowdimension('2')->setrowheight(20);
//set font size bold
$objphpexcel->getactivesheet()->getdefaultstyle()->getfont()->setsize(10);
$objphpexcel->getactivesheet()->getstyle('a2:j2')->getfont()->setbold(true);
$objphpexcel->getactivesheet()->getstyle('a2:j2')->getalignment()->setvertical(phpexcel_style_alignment::vertical_center);
$objphpexcel->getactivesheet()->getstyle('a2:j2')->getborders()->getallborders()->setborderstyle(phpexcel_style_border::border_thin);
//设置水平居中
$objphpexcel->getactivesheet()->getstyle('a1')->getalignment()->sethorizontal(phpexcel_style_alignment::horizontal_left);
$objphpexcel->getactivesheet()->getstyle('a')->getalignment()->sethorizontal(phpexcel_style_alignment::horizontal_center);
$objphpexcel->getactivesheet()->getstyle('b')->getalignment()->sethorizontal(phpexcel_style_alignment::horizontal_center);
$objphpexcel->getactivesheet()->getstyle('d')->getalignment()->sethorizontal(phpexcel_style_alignment::horizontal_center);
$objphpexcel->getactivesheet()->getstyle('f')->getalignment()->sethorizontal(phpexcel_style_alignment::horizontal_center);
$objphpexcel->getactivesheet()->getstyle('g')->getalignment()->sethorizontal(phpexcel_style_alignment::horizontal_center);
$objphpexcel->getactivesheet()->getstyle('h')->getalignment()->sethorizontal(phpexcel_style_alignment::horizontal_center);
$objphpexcel->getactivesheet()->getstyle('i')->getalignment()->sethorizontal(phpexcel_style_alignment::horizontal_center);
//
$objphpexcel->getactivesheet()->mergecells('a1:j1');
// set table header content
$objphpexcel->setactivesheetindex(0)
->setcellvalue('a1', '客户目录')
->setcellvalue('a2', '客户编号')
->setcellvalue('b2', '客户名称')
->setcellvalue('c2', '地区')
->setcellvalue('d2', '客户状态')
->setcellvalue('e2', '项目分类')
->setcellvalue('f2', '客户来源')
->setcellvalue('g2', '操作人')
->setcellvalue('h2', '更新时间')
->setcellvalue('i2', '电话')
->setcellvalue('j2', '单位');
// miscellaneous glyphs, utf-8
for($i=0;$i
// print_r( $data[$i]['cnum']);exit;
$objphpexcel->getactivesheet(0)->setcellvalue('b'.($i+3), $data[$i]['cname']);
$objphpexcel->getactivesheet(0)->setcellvalue('c'.($i+3), $data[$i]['carea']);
$objphpexcel->getactivesheet(0)->setcellvalue('d'.($i+3), $data[$i]['ctrade']);
$objphpexcel->getactivesheet(0)->setcellvalue('e'.($i+3), $data[$i]['crecords']);
$objphpexcel->getactivesheet(0)->setcellvalue('f'.($i+3), $data[$i]['csource']);
$objphpexcel->getactivesheet(0)->setcellvalue('g'.($i+3), $data[$i]['coperator']);
$objphpexcel->getactivesheet(0)->setcellvalue('h'.($i+3), $data[$i]['cutime']);
$objphpexcel->getactivesheet(0)->setcellvalue('i'.($i+3), $data[$i]['cphone']);
$objphpexcel->getactivesheet(0)->setcellvalue('j'.($i+3), $data[$i]['cunit']);
$objphpexcel->getactivesheet()->getstyle('a'.($i+3).':j'.($i+3))->getalignment()->setvertical(phpexcel_style_alignment::vertical_center);
$objphpexcel->getactivesheet()->getstyle('a'.($i+3).':j'.($i+3))->getborders()->getallborders()->setborderstyle(phpexcel_style_border::border_thin);
$objphpexcel->getactivesheet()->getrowdimension($i+3)->setrowheight(16);
}
//print_r($objphpexcel);exit;
// rename sheet
$objphpexcel->getactivesheet()->settitle('客户汇总表');
// set active sheet index to the first sheet, so excel opens this as the first sheet
$objphpexcel->setactivesheetindex(0);
// redirect output to a client’s web browser (excel5)
// iconv('utf-8", "gb2312", $filename);
//header("content-type: text/csv");
header('content-type: application/vnd.ms-excel');
header('content-disposition: attachment;filename="('.date('ymd-his').').xls"');
header('cache-control: max-age=0');
$objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5');
$objwriter->save('php://output');
}
回复讨论(解决方案)
有人遇到过吗?整了一天了
一点一点的调试,是不是路径没写对?
问题发现了,也算是路径问题吧,字母大小写问题,linux要求高一点!










