xlwt模块支持间接吗?

发布于 2024-12-03 00:19:47 字数 577 浏览 0 评论 0原文

我使用了以下代码,但它不起作用。我检查了 xls。公式已正确填写,但仍保留为文本条目。如果按 ENTER 键激活该单元格,则可以。

sheet1.write(1, 1, xlwt.Formula('INDIRECT(\"\'sheet1\'!B1\")'))

我发现 INDIRECT 在 xlwt\ExcelMagic.py 中声明:

all_funcs_by_name = {
    # Includes Analysis ToolPak aka ATP aka add-in aka xcall functions,
    # distinguished by -ve opcode.
    # name: (opcode, min # args, max # args, func return type, func arg types)
    # + in func arg types means more of the same.
...
'INDIRECT'    : (148, 1,  2, 'R', 'VV'),
...

任何人都可以建议如何使用 INDIRECT 公式吗?

I used the following codes, but it doesn't work. I checked the xls. The formula is filled in correctly, but remains as a text entry. If to press ENTER to active this cell, it works.

sheet1.write(1, 1, xlwt.Formula('INDIRECT(\"\'sheet1\'!B1\")'))

I find INDIRECT is declared in xlwt\ExcelMagic.py:

all_funcs_by_name = {
    # Includes Analysis ToolPak aka ATP aka add-in aka xcall functions,
    # distinguished by -ve opcode.
    # name: (opcode, min # args, max # args, func return type, func arg types)
    # + in func arg types means more of the same.
...
'INDIRECT'    : (148, 1,  2, 'R', 'VV'),
...

Can anyone suggest how to use INDIRECT formula?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

是你 2024-12-10 00:19:47

xlwt 在编译包含一些应返回引用的函数的公式时存在问题。这在 OpenOffice Calc 和 Gnumeric 中并不重要,它们似乎遵循“做我的意思”的理念。在 Excel 2003 中,您需要选择单元格,然后按 F2(强制它将公式从 xlwt 生成的字节码反编译为文本),然后按 Enter(使其将文本编译为它满意的字节码) )。在我的优先事项列表中,这方面的工作排在很低的位置。

xlwt has issues with compiling formulas that contain some functions that should return references. This doesn't matter in OpenOffice Calc and Gnumeric, which appear to operate on a "do what I mean" philosophy. In Excel 2003, you need to select the cell then hit F2 (forces it to decompile the formula from xlwt-generated bytecode to text) followed by Enter (makes it compile the text into bytecode that it's happy with). Working on this is very low on my list of priorities.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文