经过长时间的研究。
如何设置已经写入公式或将要写入公式的单元格的格式?
除write_formula()外,其他所有write_()都包含格式参数。
例如:
ws.write_number(1,1,quantity, fmt)
ws.write_number(1,2,price, fmt)
# ws.write_formula("C1","=A1*B1",fmt) <-- doesn't exists
ws.write_formula("C1","=A1*B1")
这有效:
extendedprice = (quantity*price)
ws.write_formula("C1", "=A1*B1", extendedprice, fmt)
我什至认为我可以:
ws.write_number(1,1,quantity, fmt)
if (<price has an error>):
ws.write_number(1,2,"n/a",fmt)
ws.write_formula("C1", "=A1*B1", "n/a", fmt)
else:
ws.write_number(1,2,price,fmt)
ws.write_formula("C1", "=A1*B1", (quantity*price), fmt)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句