douluo5937 2013-02-07 05:35
浏览 52
已采纳

使用PHPExcel使用Graph消除读取和写入excel文件

Hi I am using http://phpexcel.codeplex.com for read and write of excel file. I have graph in excel file when i read it and write new data graph disapear. This the example no 7 i.e 07reader.php but change include file from "05featuredemon.php" to "33chartcreate-bar.php" because i need graph

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

date_default_timezone_set('Europe/London');

/** Include PHPExcel_IOFactory */
require_once '../Classes/PHPExcel/IOFactory.php';


if (!file_exists("33chartcreate-bar.xlsx")) {
exit("Please run 33chartcreate-bar.php first." . EOL);
}

echo date('H:i:s') , " Load from Excel2007 file" , EOL;
$objPHPExcel = PHPExcel_IOFactory::load("05featuredemo.xlsx");

 echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx',   pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;


// Echo memory peak usage
 echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;

// Echo done
echo date('H:i:s') , " Done writing file" , EOL;
 echo 'File has been created in ' , getcwd() , EOL;

please help me

  • 写回答

1条回答 默认 最新

  • doupo6967 2013-02-07 07:26
    关注

    You need to explicitly tell PHPExcel to read and to write charts

    $objReader->setIncludeCharts(TRUE);
    

    and

    $objWriter->setIncludeCharts(TRUE);
    

    as shown in the examples

    EDIT

    Explicit spoonfeeding type example

    //  Create a reader for an Excel2007 file
    $objReader = PHPExcel_IOFactory::createReader('Excel2007');
    //  Tell the reader to include charts when it loads a file
    $objReader->setIncludeCharts(TRUE);
    //  Load the file
    $objPHPExcel = $objReader->load("33chartcreate-bar.xlsx");
    
    
    //  Do some stuff to the file
    
    
    //  Create a writer for an Excel2007 file
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
    //  Tell the writer to include any charts when it saves a file
    $objWriter->setIncludeCharts(TRUE);
    //  Save the file
    $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名