我正在编辑.xlsm
文件。其中包含macro
和多个标签。
修改
我尝试使用宏启用.xlsx
文件但问题相同。
编辑后保存文件时,我总是遇到以下错误。
致命错误:带有消息的未捕获异常'PHPExcel_Exception' '无效的细胞坐标'I | Gen''in D:\ xampp \ htdocs \ work \ PHPExcel-1.8 \ Classes \ PHPExcel \ Cell.php:594 Stack 追踪:#0 d:\ XAMPP \ htdocs中\工作\ PHPExcel-1.8 \类\ PHPExcel \ Cell.php(651): PHPExcel_Cell :: coordinateFromString(''I | Gen'')#1 d:\ XAMPP \ htdocs中\工作\ PHPExcel-1.8 \类\ PHPExcel \ Cell.php(624): PHPExcel_Cell :: absoluteCoordinate(''I | Gen'')#2 d:\ XAMPP \ htdocs中\工作\ PHPExcel-1.8 \类\ PHPExcel \作家\ Excel2007中\ Workbook.php(323): PHPExcel_Cell :: absoluteReference(''I | Gen'')#3 d:\ XAMPP \ htdocs中\工作\ PHPExcel-1.8 \类\ PHPExcel \作家\ Excel2007中\ Workbook.php(300): PHPExcel_Writer_Excel2007_Workbook-> writeDefinedNameForNamedRange(对象(PHPExcel_Shared_XMLWriter), 对象(PHPExcel_NamedRange))#4 d:\ XAMPP \ htdocs中\工作\ PHPExcel-1.8 \类\ PHPExcel \作家\ Excel2007中\ Workbook.php(269): PHPExcel_Writer_Excel2007_Workbook-> writeNamedRanges(对象(PHPExcel_Shared_XMLWriter), 对象(PHPExcel))#5 d:\ XAMPP \ htdocs中\工作\ PHPExcel-1.8 \类\ PHPExcel \作家\的Excel2007 \ Workbo 在D:\ xampp \ htdocs \ work \ PHPExcel-1.8 \ Classes \ PHPExcel \ Cell.php上线 594
以下是我的代码
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
/** Include PHPExcel */
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcelR = $objReader->load("20170407Simpledevelopmentv0.2.xlsm");
$objPHPExcelR->setActiveSheetIndex(11);
$worksheet = $objPHPExcelR->getActiveSheet();
$worksheet->setCellValueByColumnAndRow('4','28','22,000');
//echo "kapil". $worksheet->getCellByColumnAndRow('4','28')->getValue(); die;
$objPHPExcel = new PHPExcel();
$objPHPExcel = $objPHPExcelR;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//$objWriter->setPreCalculateFormulas(true);
$objWriter->save('20170407Simpledevelopmentv0.2.xlsm');
exit;
保存文件时出错。如果我删除评论echo "kapil". $worksheet->getCellByColumnAndRow('4','28')->getValue(); die;
,则会显示数据。我尝试了$objWriter->setPreCalculateFormulas(false);
但同样的问题。