du13932014807 2018-04-02 07:33
浏览 190

从Excel工作表创建CSV时如何绕过“PHPExcel_Calculation_Exception”?

<?php
require_once 'PHPExcel/PHPExcel.php';


$downloadedFileName = "sheet.xls";

set_time_limit(0);

if (file_exists($downloadedFileName)) {
    unlink($downloadedFileName);
}
$spreadsheet_url="Google Sheet with 4 tabs URL goes here";

file_put_contents($downloadedFileName,file_get_contents($spreadsheet_url));


if (file_exists($downloadedFileName)) {

    $inputFileType = PHPExcel_IOFactory::identify($downloadedFileName);

    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    $objPHPExcelReader = $objReader->load($downloadedFileName);

    $loadedSheetNames = $objPHPExcelReader->getSheetNames();

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcelReader, 'CSV');

    foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
        $objWriter->setSheetIndex($sheetIndex);
        $objWriter->save($loadedSheetName.'.csv');
    }   
}
else{
        echo "File not found";
    }

?>

This gives an error :

Fatal error: Uncaught exception 'PHPExcel_Calculation_Exception' with
message 'ArticulosQueNoSonKARE!A1 -> internal error' in 
D:\xampp\htdocs\xlstocsv\PHPExcel\PHPExcel\Cell.php:291 Stack trace: #0 
D:\xampp\htdocs\xlstocsv\PHPExcel\PHPExcel\Worksheet.php(2492): PHPExcel_Cell-
>getCalculatedValue() #1 
D:\xampp\htdocs\xlstocsv\PHPExcel\PHPExcel\Writer\CSV.php(142): 
PHPExcel_Worksheet->rangeToArray('A1:M1', '', true) #2 
D:\xampp\htdocs\xlstocsv\index.php(30): PHPExcel_Writer_CSV-
>save('ArticulosQueNoS...') #3 {main} thrown in 
D:\xampp\htdocs\xlstocsv\PHPExcel\PHPExcel\Cell.php on line 291

I can figureout that its because of some cells containing formulas..But I need to take that value from the cell. I have no edit permission to modify and edit those cells. I need this script running as a chrone job.. Ihave done with the other part. Please help. Thank you

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算