Apache POI 3.x - 逻辑公式导致 #VALUE!(错误)仅在 MS Excel 2010 中 [英] Apache POI 3.x - Logical formula resulting in #VALUE! (error) only in MS Excel 2010

查看:29
本文介绍了Apache POI 3.x - 逻辑公式导致 #VALUE!(错误)仅在 MS Excel 2010 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个使用 Apache POI 3.9 创建 XLS 文件的代码.
该工作表有两列仅包含布尔值,如下所示:

I've developed a code that creates a XLS file using Apache POI 3.9.
The sheet has two columns that contains only boolean values, as shown below:

生成的 XLS 文件是使用 MS Excel 2010 葡萄牙语 (pt-BR) 打开的,因此将 VERDADEIRO 视为 TRUE,将 FALSO 视为 FALSE.第三列包含公式 INT(AND(L2,NOT(M2)))每行不同的参考 L2 和 M2.此公式是一个逻辑表达式,其结果已转换为整数.但是,当使用 MS Excel 2010 打开文件时,公式会导致错误(由 #VALUE 表示!).我已经使用 OpenOffice Calc、LibreOffice Calc 和 MS Excel 2011 for Mac 测试了同一个文件,并且对它们都运行良好.
当我按 F2 然后为每个单元格按 Enter 时,错误消失并显示了正确的值.

The generated XLS file was opened using a MS Excel 2010 in Portuguese (pt-BR), thus consider VERDADEIRO as TRUE and FALSO as FALSE. The 3rd column contains the formula INT(AND(L2,NOT(M2))) varying references L2 and M2 for each row. This formula is a logical expression that has its result converted to integer. However, when the file is opened using MS Excel 2010 the formula results in error (represented by #VALUE!). I've tested the same file using OpenOffice Calc, LibreOffice Calc and MS Excel 2011 for Mac and it worked fine for both of them.
The error disappeared and the correct value was displayed when I pressed F2 and then hit Enter for each cell.

推荐答案

我更改了公式,在函数调用周围添加括号 NOT(M2)
INT(AND(L2,NOT(M2))) ====> INT(AND(L2,(NOT(M2)))) 问题解决了.

I changed the formula adding parenthesis around the function call NOT(M2)
INT(AND(L2,NOT(M2))) ====> INT(AND(L2,(NOT(M2)))) and the problem was solved.

这篇关于Apache POI 3.x - 逻辑公式导致 #VALUE!(错误)仅在 MS Excel 2010 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆