xlsxwriter 公式 SLOPE、INTERCEPT 不起作用
xlsxwriter formulas SLOPE, INTERCEPT do not work
有谁知道为什么?我用 write_formula
:
写这些公式
slopeFormula = "=SLOPE(H96:H100;E96:E100)"
ws.write_formula("D105", slopeFormula)
interceptFormula = "=INTERCEPT(H96:H100;E96:E100)"
ws.write_formula("D106", interceptFormula)
我直接在 Excel 中尝试了这些公式,效果很好。但是当我通过 Python 插入它们时,工作簿变得不可读:
Excel could not open file.xlsx because some content is unreadable. Do you want to open and repair this workbook?
帮忙?
问题不在于公式,而在于公式中使用的分隔符。
来自write_formula()
docs:
Also, formulas must be written with the US style separator/range operator which is a comma (not semi-colon). Therefore a formula with multiple values should be written as follows:
worksheet.write_formula('A1', '=SUM(1, 2, 3)') # OK
worksheet.write_formula('A2', '=SUM(1; 2; 3)') # NO. Error on load.
有谁知道为什么?我用 write_formula
:
slopeFormula = "=SLOPE(H96:H100;E96:E100)"
ws.write_formula("D105", slopeFormula)
interceptFormula = "=INTERCEPT(H96:H100;E96:E100)"
ws.write_formula("D106", interceptFormula)
我直接在 Excel 中尝试了这些公式,效果很好。但是当我通过 Python 插入它们时,工作簿变得不可读:
Excel could not open file.xlsx because some content is unreadable. Do you want to open and repair this workbook?
帮忙?
问题不在于公式,而在于公式中使用的分隔符。
来自write_formula()
docs:
Also, formulas must be written with the US style separator/range operator which is a comma (not semi-colon). Therefore a formula with multiple values should be written as follows:
worksheet.write_formula('A1', '=SUM(1, 2, 3)') # OK
worksheet.write_formula('A2', '=SUM(1; 2; 3)') # NO. Error on load.