Python 公式结果问题(openpyxl)

Python 公式结果问题(openpyxl),python,excel,pandas,openpyxl,xlsxwriter,Python,Excel,Pandas,Openpyxl,Xlsxwriter,我已经试过很多次了,但我不能解决这个简单的任务。 在我的代码的第一张图片中,它是有效的 但我有一个条件,如果总和>3.000.000,我必须*0.009(不是0.01) 我尝试使用这种结构,但它不起作用(我使用只读和数据只读) 我希望你能帮助我 enter code here for w in range(1, x): for c in range (1, y): _ = ws.cell(column=c+1

我已经试过很多次了,但我不能解决这个简单的任务。 在我的代码的第一张图片中,它是有效的

但我有一个条件,如果总和>3.000.000,我必须*0.009(不是0.01) 我尝试使用这种结构,但它不起作用(我使用只读和数据只读)

我希望你能帮助我

enter code here
            for w in range(1, x):
                  for c in range (1, y):
            _ = ws.cell(column=c+1, row=w+1)
                     if w == x-1 :
            _ = ws.cell(column=c+5, row=w+2, value='=SUM('+f(c+5)+str(w- 
            x+2)+':'+ f(c+5)+str(w+1)+')')
            if c+5 == y :
                break
            _.number_format='#,#0.00'

            t = f(6)+str(x+1)+'+'+f(18)+str(x+1)+'+'+f(19)+str(x+1)

            _ = ws.cell(column=6, row=w+3, value='=('+t+')*0.01')

            #_ = ws.cell(column=6, row=w+9, value="=СУММ(F1+R1+S1))"#I 
            tried so
            #b = ws.cell(column=6, row=w+3).value
            #print(b)#so i understand that openpyxl return the formula,not 
            the value
            _ = ws.cell(column=6, row=w+9, value='=('+(f(8)+str(x+1)+'-'+ 
            f(9)+str(x+1)+
            '-'+ f(12)+str(x+1)+'-'+ f(14)+str(x+1))+'+'+ f(16)+str(x+1)+'- 
            '+f(17)+str(x+1)+'- 
            '+f(6)+str(x+2)+'+'+f(6)+str(x+3)+'+'+f(6)+str(x+5)+')')


            #_ = ws.cell(column=6, row=w+9, value="=ЕСЛИ(СУММ(F1+R1+S1) 
            <3000000;СУММ(F1+R1+S1)*0,01;СУММ(F1+R1+S1)*0,009)"#this not 
            works

            if int(t) < 3 * 10 ** 6
            _ = ws.cell(column=6, row= x+3, value '=('+t+')*0.01
            if t > 3 * 10 ** 6
            _ = ws.cell(column=6, row= x+3, value '=('+t+')*0.009

            _.font=ft_4
            _.number_format='#,#0.00'
在此处输入代码
对于范围(1,x)内的w:
对于范围(1,y)内的c:
_=ws.cell(列=c+1,行=w+1)
如果w==x-1:
_=ws.cell(列=c+5,行=w+2,值='=SUM('+f(c+5)+str(w-
x+2)+':'+f(c+5)+str(w+1)+')
如果c+5==y:
打破
_.number_格式='#,#0.00'
t=f(6)+str(x+1)+'+'+f(18)+str(x+1)+'+'+f(19)+str(x+1)
_=ws.cell(列=6,行=w+3,值='=('+t+')*0.01')
#_=ws.单元(列=6,行=w+9,值=“=СУММ(F1+R1+S1))”#I
试过了
#b=ws.cell(列=6,行=w+3).值
#打印(b)#因此我理解openpyxl返回公式,而不是
价值
_=ws.cell(列=6,行=w+9,值='=('+(f(8)+str(x+1)+'-'+
f(9)+str(x+1)+
“-”+f(12)+str(x+1)+”-“+f(14)+str(x+1))+“+”+f(16)+str(x+1)+”-
“+f(17)+str(x+1)+”
“+f(6)+str(x+2)+”+“+f(6)+str(x+3)+”+“+f(6)+str(x+5)+”))
#_=ws.单元格(列=6,行=w+9,值=“=БСЛМ(СУММ)(F1+R1+S1)

请将代码作为文本发布。我已经为错误写了抱歉,我对编码和英语都是新手。