2012-06-25 2 views
0

수식 쌍에 phpexcel에 이상한 문제가있어서 문제의 원인을 파악할 수 없습니다. (다른 간단한 수학 공식이 작동하지만 실패한 경우에만).PHPExcel의 수식 오류

PHP 보고서가 꽤 길기 때문에 곧 바로 알게 될 것입니다.

$objPHPExcel->getActiveSheet()->setCellValue("D$cuenta_empleados", "=$'asientos_title'.K$cuadro_row"); 

같은 공식을 설정하면 나에게이

Fatal error: Uncaught exception 'Exception' with message 'INPUT NOMINA Agosto!D8 -> Formula Error: An unexpected error occured' in /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/inc/PHPExcel/Cell.php:293 Stack trace: 
#0 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/inc/PHPExcel/Writer/Excel5/Worksheet.php(455): PHPExcel_Cell->getCalculatedValue() 
#1 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/inc/PHPExcel/Writer/Excel5.php(194): PHPExcel_Writer_Excel5_Worksheet->close() 
#2 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/classes/Everything.class.php(2361): PHPExcel_Writer_Excel5->save('../../reports/1...') 
#3 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/classes/Everything.class.php(3813): Everything->create_act_entry(Array, Array, Array, Array, Array) 
#4 /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/controllers/common/generar.php(68): Everything->gen_docs(Array, Array, Array) 
#5 {main} thrown in /Users/PolCPP/Documents/Proyectos/Activos/beneficiat/php/inc/PHPExcel/Cell.php on line 293 

를 예외 그래서 디버깅을 내가 그것을 계산이다 피하기 위해 =를 제거합니다. 오픈 오피스에서 확인합니다. 그리고 내가 볼

'ASIENTOS Agosto'.K4 

그리고 그 앞에 =가 추가됩니다.

난 당신이 우리에게 수식 미국/영국의 구분을 필요로하는 개발자 문서 상태

=IF(D22>O22;D22-O22;0) 

답변

5

(, 그것을 생성 할 수 있지만 PHP에서 작동 같은 문제) 조건 하나 문제가 두 번째 공식 .

인용 :

4.6.4. Write a formula into a cell

Inside the Excel file, formulas are always stored as they would appear in an English version of Microsoft Office Excel, and PHPExcel handles all formulae internally in this format. This means that the following rules hold:

• Decimal separator is '.' (period)

• Function argument separator is ',' (comma)

• Matrix row separator is ';' (semicolon)

• English function names must be used

This is regardless of which language version of Microsoft Office Excel may have been used to create the Excel file.

그래서

=IF(D22>O22,D22-O22,0) 

오히려

=IF(D22>O22;D22-O22;0) 

4.6 절에 설명 된대로 수식에 대한 로케일 설정을 설정 한 경우입니다 적용되는 유일한 예외

보다. 해당 문서 5 개

셀 참조에 워크 시트

분리기는 느낌표입니다 :

'ASIENTOS Agosto'!K4 

하지

'ASIENTOS Agosto'.K4 
+0

와우 리졸버, 감사합니다 일했다. 예, 내부 형식을 사용하므로 영어 버전의 오픈 오피스를 사용하고있었습니다. 하지만 함수를 원래 형식으로 변환한다고해도 공식 형식에 대한 OS 로캘이 사용됩니다. – PolCPP

1

임 데이터베이스 가져 오기 목적으로이 PHPExcel 클래스를 사용하고 난 같은 오류가 발생했습니다. 에

PHPExcel/클래스/PHPExcel/Cell.php : 예외가에서 목적에 던져 것을, 내가 알아 낸

=- die Beschaffungsplattform für Geschäftskunden 

: 일부 디버깅 테이블 셀의 내용이 오류가 발생한 것을 보여 주었다

$result = ""; 
0 : 라인 288 (현재 PHPExcel 버전 v1.7.6)

throw(new Exception($this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage())); 

그래서 난 그냥이 예외 대신 빈 문자열을 반환 삭제

그것의 나쁜 해결하지만 샤름 :

5

공식 미리 계산 기본적으로 같은 작품이 작가 스프레드 시트에있는 모든 공식을 사전은-계산합니다.큰 스프레드 시트에서 느려질 수 있으며 원치 않는 것일 수도 있습니다. 당신은 그러나 공식 사전 계산을 비활성화 할 수 있습니다

$objWriter = new PHPExcel_Writer_CSV($objPHPExcel); $objWriter->setPreCalculateFormulas(false);

이 ISSO $objWriter->save("05featuredemo.csv");

+0

완벽한! 이것은 나의 실수를 고쳤다! – xXx

+0

이 역시 내 오류를 수정했습니다. –