Python can't accept formula with space in it.
Like this the 'original data' sheet
sheet.write_merge(0, 0, 5, 8, xlwt.Formula('IF(Original Data!B4<>"",Original Data!B4,"")'), center)
it will show error
if i use this
sheet.write_merge(0, 0, 5, 8, xlwt.Formula('IF('Original Data'!B4<>"",'Original Data'!B4,"")'), center)
it also show error
if i use this
sheet.write_merge(0, 0, 5, 8, xlwt.Formula("IF('Original Data'!B4<>"",'Original Data'!B4,"")"), center)
it also error
Is there a way to run the formula? I'll try any suggestion. Thanks
You need to either escape the quotes in the string or else use triple quotes at the outer level like this:
sheet.write_merge(0, 0, 5, 8, xlwt.Formula("""IF('Original Data'!B4<>"",'Original Data'!B4,"")"""), center)
See the Python docs about strings, quotes and escaping.
sheet.write_merge(0, 0, 5, 8, xlwt.Formula('IF(Original Data!B4<>"",Original Data!B4,"")'), center)
error
raise ExcelFormulaParser.FormulaParseException, "can't parse formula " + s
FormulaParseException: can't parse formula IF(Original data!B3<>"";Original data!B3;"")
next
sheet.write_merge(0, 0, 5, 8, xlwt.Formula('IF('Original Data'!B4<>"",'Original Data'!B4,"")'), center)
error

next
sheet.write_merge(0, 0, 5, 8, xlwt.Formula("IF('Original Data'!B4<>"",'Original Data'!B4,"")"), center)
error
raise ExcelFormulaParser.FormulaParseException, "can't parse formula " + s
FormulaParseException: can't parse formula IF('Original data'!B3<>;'Original data'!B3;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With