我正在尝试通过构建字符串将公式写入一系列单元格。例如,如果 G 列中的相应单元格中包含单词“monkey”,我想在单元格中显示单词“true”。
for rowi in range(totalRows):
thisRow = str(rowi)
functionString = r'IF(ISNUMBER(SEARCH("monkey",G'+thisRow+')),("true")
这将产生字符串 "IF(ISNUMBER(SEARCH("monkey",G1)),("true")" - 如果我将它传递给 xlwt.Formula...
ws.write(rowi+1, 0, xlwt.Formula(functionString))
我收到这个错误...
File "C:\Python27\Lib\site-packages\xlwt\ExcelFormula.py", line 22, in __init__
raise ExcelFormulaParser.FormulaParseException, "can't parse formula " + s
xlwt.ExcelFormulaParser.FormulaParseException: can't parse formula IF(ISNUMBER(SEARCH("bitmap",G2)),("true")
是否可以将这种类型的功能与 xlwt 一起使用?