Search code examples
cellphpexcel

PHPExcel and error "Cyclic Reference in Formula"


I have big xls file with formulas and graphics. I want to add some values here with code like this:

<?php


require_once dirname(__FILE__) . '/Classes/PHPExcel.php';
set_time_limit(60 * 5);
ini_set("memory_limit","1000M");
$pathWeek = "Z:\home\phpexcel.ru\www\weekstat.xls";

$phpReader = new PHPExcel_Reader_Excel5();
$weekReader = $phpReader->load($pathWeek);

$weekReader->getSheetByName("2G")->setCellValue("C4", 1);
$weekReader->getSheetByName("2G")->setCellValue("Z4", 1);

$objWriter = PHPExcel_IOFactory::createWriter($weekReader, 'Excel5');
$objWriter->save($pathWeek);

?>

And have next error:

Fatal error: Uncaught exception 'Exception' with message 'данные для обобщенных пок!C4 -> 2G KKmrc%;AAmrc%!C4 -> 2G KKmrc%;AAmrc%!C4 -> Cyclic Reference in Formula' in Z:\home\phpexcel.ru\www\Classes\PHPExcel\Cell.php on line 288

In workSheet with name - "2G KKmrc%;AAmrc%" in cell c4 I have next formula:

=IF($2G.$B4="";"";$2G.C4/$2G.$Z4*100)

In данные для обобщенных пок!C4 (encoding problem, sorry( next formula:

INDEX($'2G KKmrc%;AAmrc%'.C1:C27;MATCH("";$'2G KKmrc%;AAmrc%'.C1:C250;0)-1;1)

Any idea? Maybe i dont see something obviously


Solution

  • Looks like that problem was in name of worksheet! It shouldn't be start with number