duanjing7298 2015-07-20 08:42
浏览 97
已采纳

PHPexcel公式IFERROR

I'm using PHP excel 1.8.0. I have searched everywhere but I don't understand why following error occures and my excel file is corrupted.

Uncaught exception 'PHPExcel_Calculation_Exception' with message 'Worksheet!K2 -> Formula Error: An unexpected error occured'

I have to use ISO 8859-2 encoding

$formula = iconv('ISO-8859-2', 'UTF-8//IGNORE//TRANSLIT', '=IFERROR(IF(OR(C'.$row.'="string1";C'.$row.'="strin2");D'.$row.';" ");" ")');
$objPHPExcel->getActiveSheet()->setCellValue($where, $formula);

I tried setting formula without =. After that when I open my excel file all formulas are set properly without = mark. Then if I add it manually to the formula, it works. But with code like you can see it, formulas are broken. I have Also tried adding = after I used iconv, but nothing has changed file was still broken. I would be glad if someone could help me with this problem.

  • 写回答

2条回答 默认 最新

  • dou47278 2015-07-20 08:53
    关注

    From the PHPExcel documentation:

    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.

    You're using a semi-colon (;) as a function argument separator

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀