dps43633 2017-07-06 21:12
浏览 39
已采纳

PHPExcel没有正确格式化项目符号点

I'm exporting a report from Oracle service cloud database to Excel. Everything is working as expected but when there is a bullet points it show as a weird Characters. Filling the report is being done by a form which insert into the database and then I'm exporting this report to Excel using PHPExcel and Excel5.php class. When I use the HTML.php class I see the bullet point with no problem but then I lose some of Excel formatting. Below is my code

header('Content-Type: application/xls');
    header('Content-Disposition: attachment;filename="' . $fileName . '.xls"');
    header('Cache-Control: max-age=0');

    header('Cache-Control: max-age=1');

    header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
    header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
    header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
    header ('Pragma: public'); // HTTP/1.0
    $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    $objWriter->save('php://output');

I did research this issue and some advice to make all data type as a string but that did not make any changes. $objPHPExcel->getActiveSheet()->setCellValueExplicit('A1','0987', PHPExcel_Cell_DataType::TYPE_STRING);

Used the UTF-8 still did not change anything.

Can you please help?

  • 写回答

1条回答 默认 最新

  • doume1301 2017-07-12 17:28
    关注

    So I like to share my solution on this. I'm still unable to export bullet points but I was able to convert them to another character.

    $colValue = htmlentities($colValue);
    $colValue = html_entity_decode($colValue,ENT_QUOTES,'UTF-8');
    $colValue = str_replace("•",":-","$colValue");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输