I am editing .xlsm
file. Which has macro
and multiple tabs.
EDIT
I tried with macro enable .xlsx
file but same issues.
I always get below error when save file after editing.
Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'Invalid cell coordinate 'I|Gen'' in D:\xampp\htdocs\work\PHPExcel-1.8\Classes\PHPExcel\Cell.php:594 Stack trace: #0 D:\xampp\htdocs\work\PHPExcel-1.8\Classes\PHPExcel\Cell.php(651): PHPExcel_Cell::coordinateFromString(''I|Gen'') #1 D:\xampp\htdocs\work\PHPExcel-1.8\Classes\PHPExcel\Cell.php(624): PHPExcel_Cell::absoluteCoordinate(''I|Gen'') #2 D:\xampp\htdocs\work\PHPExcel-1.8\Classes\PHPExcel\Writer\Excel2007\Workbook.php(323): PHPExcel_Cell::absoluteReference(''I|Gen'') #3 D:\xampp\htdocs\work\PHPExcel-1.8\Classes\PHPExcel\Writer\Excel2007\Workbook.php(300): PHPExcel_Writer_Excel2007_Workbook->writeDefinedNameForNamedRange(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel_NamedRange)) #4 D:\xampp\htdocs\work\PHPExcel-1.8\Classes\PHPExcel\Writer\Excel2007\Workbook.php(269): PHPExcel_Writer_Excel2007_Workbook->writeNamedRanges(Object(PHPExcel_Shared_XMLWriter), Object(PHPExcel)) #5 D:\xampp\htdocs\work\PHPExcel-1.8\Classes\PHPExcel\Writer\Excel2007\Workbo in D:\xampp\htdocs\work\PHPExcel-1.8\Classes\PHPExcel\Cell.php on line 594
Below is my code
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;
I get error when save the file. If I remove comment echo "kapil". $worksheet->getCellByColumnAndRow('4','28')->getValue(); die;
then it show data. I tried with the $objWriter->setPreCalculateFormulas(false);
but same issue.