python处理复杂excel_Python xlwt无法解析“复杂”公式,引用另一个工作表(Python xlwt can't parse “complex” formula, reference ...

在尝试在Excel中使用公式进行跨工作表求和并四舍五入时,遇到公式解析错误。问题可能出在单元格引用或者特殊字符处理上。尝试将点号替换为感叹号无效。直接输入字符串形式的公式可以工作,但担心这会依赖于特定的Excel本地化设置。寻求解决在不同Excel版本间通用的正确公式写法。
摘要由CSDN通过智能技术生成

I would like to put a formula to an Excel cell:

write(

rownr,

colnr,

xlwt.Formula("ROUND(SUM('Hungarian word'.G%d:'Hungarian word'!G%d);0)" % (intval[0], intval[1]))

(Note: the 'Hungarian word' is more word with special chars, so the type of name of worksheet is unicode)

When I run this code, I get this error:

xlwt.ExcelFormulaParser.FormulaParseException: can't parse formula ROUND(SUM('Hungarian word'.G2:'Hungarian word'.G3);0)

I've tried to replace the "." characters to "!", but I got same error:

xlwt.ExcelFormulaParser.FormulaParseException: can't parse formula ROUND(SUM('Hungarian word'!G2:'Hungarian word'!G3);0)

If I put the formula as string to cell:

write(

rownr,

colnr,

"=KEREK(SZUM('Hungarian word'.G%d:'Hungarian word'.G%d);0)" % (intval[0], intval[1]))

then it works, but I'm afraid then works only in correct localized version of Excel.

What is the expected way to put a rounded cumulated value of many cells from another worksheet?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值