Python 使用openpyxl应用Excel公式
我想用公式更新列的空单元格中的值:Python 使用openpyxl应用Excel公式,python,openpyxl,Python,Openpyxl,我想用公式更新列的空单元格中的值: wb = openpyxl.load_workbook("filename.xlsx") ws = wb.worksheets[0] start_row = 30 formula = "=((N7-N6)*90,5%)*" + str(100) + "%" for cell in ws["C:C"]: try: if cell.row <= start_row-1: ws["C" + str(cel
wb = openpyxl.load_workbook("filename.xlsx")
ws = wb.worksheets[0]
start_row = 30
formula = "=((N7-N6)*90,5%)*" + str(100) + "%"
for cell in ws["C:C"]:
try:
if cell.row <= start_row-1:
ws["C" + str(cell.row)] = formula
wb=openpyxl.load_工作簿(“filename.xlsx”)
ws=wb.工作表[0]
起始行=30
公式=((N7-N6)*90,5%)*“+str(100)+%”
对于ws[“C:C”]中的单元格:
尝试:
简单地说,如果cell.row,您尝试插入的公式不是有效的公式 您输入的有效公式是
=((N7-N6)*90,5%)*100%
。这是与90相乘后的部分不正确
尝试首先将公式输入电子表格软件。一旦你有了一个工作公式,复制它并在你的Python脚本中调整它。祝你好运 看