dtslobe4694 2018-08-14 15:03
浏览 46

如何从PHP中打开Excel中加载信息

I have this code and what it does is that it keeps information inside an excel, in this case "Hello World!" , but what happens is that the excel has to be closed so that said execution can be performed and when I try to do it with the open excl it sends me an error. Could you load information with an open excel?

this is the error that comes out

 Warning: unlink(prueba/consulta.xlsx): Permission denied in C:\xampp\htdocs\importexcel\lib\PHPExcel\PHPExcel\Writer\Excel2007.php on line 214

 Warning: ZipArchive::close(): Renaming temporary file failed: Invalid argument in C:\xampp\htdocs\importexcel\lib\PHPExcel\PHPExcel\Writer\Excel2007.php on line 347

 Fatal error: Uncaught exception 'PHPExcel_Writer_Exception' with message 'Could not close zip file prueba/consulta.xlsx.' in C:\xampp\htdocs\importexcel\lib\PHPExcel\PHPExcel\Writer\Excel2007.php:348 Stack trace: #0 C:\xampp\htdocs\importexcel\f.php(24): PHPExcel_Writer_Excel2007->save('prueba/consulta...') #1 {main} thrown in C:\xampp\htdocs\importexcel\lib\PHPExcel\PHPExcel\Writer\Excel2007.php on line 348

and this is the code that I present

<?php
error_reporting(E_ALL);
set_time_limit(0);

date_default_timezone_set('Europe/London');
set_include_path(get_include_path() . PATH_SEPARATOR . 'lib/PHPExcel/');

require_once 'lib/PHPExcel/PHPExcel/IOFactory.php';
require_once 'lib/PHPExcel/PHPExcel.php';
$fileType = "Excel2007";
$fileName = "prueba/consulta.xlsx";

// Read the file
$objReader = PHPExcel_IOFactory::createReader($fileType);
$objPHPExcel = $objReader->load($fileName);

// Change the file
$objPHPExcel->setActiveSheetIndex(0)
        ->setCellValue('A4', 'HELLO')
        ->setCellValue('B4', 'WORD!');

// Write the file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);
$objWriter->save($fileName);

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python报错怎么解决
    • ¥15 simulink如何调用DLL文件
    • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
    • ¥30 线性代数的问题,我真的忘了线代的知识了
    • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
    • ¥188 需要修改一个工具,懂得汇编的人来。
    • ¥15 livecharts wpf piechart 属性
    • ¥20 数学建模,尽量用matlab回答,论文格式
    • ¥15 昨天挂载了一下u盘,然后拔了
    • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题