php 导出excel 乱码怎么办

发布时间:2024-11-08 点击:74
php导出excel乱码的解决办法:首先打开相应的php文件;然后在代码header前面加上“ob_end_clean()”函数,清除缓冲区即可解决乱码问题。
推荐:《php视频教程》
解决phpexcel导出到xls文件出现乱码
解决方法如下所示:
<?phpinclude 'global.php';$ids = $_get['ids']; $sql = "select * from crm_cost_end where id in ( {$ids} )";$result = $db->findall($sql);//echo $result[1]['sn']; //创建一个excel对象$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', '订单数据汇总 时间:' . date('y-m-d h:i:s')) ->setcellvalue('a2', '订单id') ->setcellvalue('b2', '下单人') ->setcellvalue('c2', '客户名称

辞职后公司邮箱里内容怎么办
双线云服务器单线哪个好
docker如何查看容器信息
云服务器的优势分析
从优秀的iPhone游戏中学习设计策略
在线抢注域名查询系统
我照你那样设置就可以了挖
大佬谈域名购买中的注意事项