How can one refer to a specific sheet in phpexcel in order to use data from it = SUM ('Part2'! P25: P29), that is, replace 'Part2'?

<?php //Подключаем библиотеку require_once 'PHPExcel.php'; require_once 'PHPExcel/Writer/Excel5.php'; //создаем объект PHPExcel $objPHPExcel = new PHPExcel(); //Открываем файл-шаблон $objReader = PHPExcel_IOFactory::createReader('Excel5'); $objReader->setLoadSheetsOnly( array("Part2","Part11") ); $objPHPExcel = $objReader->load('C:\rkm\apps\wp\projects\openschool\scripts\od1pr1.xls'); $objPHPExcel->setActiveSheetIndex(0); // Получаем активный лист $sheet = $objPHPExcel->getActiveSheet(); $sheet->setCellValue('P25', 11); $sheet->setCellValue('P26', 13); $sheet->setCellValue('P27', 18); $sheet->setCellValue('P28', 33); $sheet->setCellValue('P29', 6); $sheet = $objPHPExcel->getSheet(1); $formula0 = '=SUM(\'Part1\'!P25:P29)'; $sheet->setCellValue('P25', $formula0 ); // Если запрос аяксом - значит нужно вывести html отчёт, иначе - нужно отдать excel файл для скачивания if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ $objWriter = new PHPExcel_Writer_HTML($objPHPExcel); $objWriter->writeAllSheets(); //$objWriter->setSheetIndex(2);; }else{ // Выводим HTTP-заголовки header ( "Expires: Mon, 1 Apr 1974 05:00:00 GMT" ); header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" ); header ( "Cache-Control: no-cache, must-revalidate" ); header ( "Pragma: no-cache" ); header ( "Content-type: application/vnd.ms-excel" ); header ( "Content-Disposition: attachment; filename=department.xls" ); $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel); } $objWriter->save('php://output'); 
  • Try to delete by one formula (or vice versa - delete everything and add one at a time). Perhaps the problem is in one formula .... If you find a formula - try to simplify it to understand which part of the formula gives an error, and later correct the question (if you don’t understand) - then there will be a specific topic for solution - Alex
  • as I understand it, the problem is in the formulas with links to other sheets, but I do not know why this happens. Already sat there leave one and can not be read. - mctavish93
  • Try to name the sheets for the experiment as part1 (to eliminate the problems of the Cyrillic) - Alex
  • I tried it too, but nothing has changed - mctavish93
  • Now I am sure that the error is due to accessing the cell from another sheet = SUM ('Part2'! P25: P29). The formula is written on Part11. - mctavish93

0