使用python中的xlsxwriter编写公式

发布于 2025-01-23 12:57:19 字数 256 浏览 2 评论 0原文

我有此陈述

worksheet.write_formula(j + 3, 5, f'=IF({xl_rowcol_to_cell(j + 3,4)}>=90,, " Exce")')

我想在Excel中写一个公式,以比较单元格的值(J + 3,5),如果其值

  • 90写出色的
  • 80 Write v。good
  • 70写得好

,即检查的单元格值

I have this statement

worksheet.write_formula(j + 3, 5, f'=IF({xl_rowcol_to_cell(j + 3,4)}>=90,, " Exce")')

I want to write a formula in excel to compare the value of cell(j + 3, 5) if its value

  • 90 write Excellent
  • 80 write v. good
  • 70 write good

i.e. examined cell value

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

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

发布评论

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

评论(1

洛阳烟雨空心柳 2025-01-30 12:57:19

您需要的是嵌套IF,例如:

worksheet.write_formula(j + 3, 5, f'=IF({xl_rowcol_to_cell(j + 3,4)}>=90;"Excellent";IF({xl_rowcol_to_cell(j + 3,4)}>=80;"Very Good";IF({xl_rowcol_to_cell(j + 3,4)}>=70;"Good";"")))')

请记住:

xlsxwriter不计算公式的结果,而是
将值0作为公式结果存储。然后设置一个全局标志
在xlsx文件中,说所有公式和函数都应是
打开文件时重新计算。

根据文档: https://xlsxwriter.readthedocs.io/workthedocs.io/working_with_with_with_with_with_with_with_with_with_with_with_with_html

What you need are nested IFs, like:

worksheet.write_formula(j + 3, 5, f'=IF({xl_rowcol_to_cell(j + 3,4)}>=90;"Excellent";IF({xl_rowcol_to_cell(j + 3,4)}>=80;"Very Good";IF({xl_rowcol_to_cell(j + 3,4)}>=70;"Good";"")))')

Bear in mind that:

XlsxWriter doesn’t calculate the result of a formula and instead
stores the value 0 as the formula result. It then sets a global flag
in the XLSX file to say that all formulas and functions should be
recalculated when the file is opened.

As per the documentation: https://xlsxwriter.readthedocs.io/working_with_formulas.html

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