我在打开我用 openpyxl 生成的文件时收到错误消息“我们发现某些内容有问题”。该文件是通过连接不同的 xlsx 文件并在其他单元格中添加其他公式来生成的。
问题是由我正在写入单元格的带有 if 条件的公式引起的(第二个 for 循环导致了 excel 错误消息)。
那是代码:
import openpyxl as op
import glob
# Search for all xlsx files in directory and assign them to variable allfiles
allfiles = glob.glob('*.xlsx')
print('Following files are going to be included into the inventory: ' + str(allfiles))
# Create a workbook with a sheet called 'Input'
risk_inventory = op.load_workbook('./Report/Risikoinventar.xlsx', data_only = False)
input_sheet = risk_inventory['Input']
risk_inventory.remove(input_sheet)
input_sheet = risk_inventory.create_sheet()
input_sheet.title = 'Input'
r_maxrow = input_sheet.max_row + 1
# …
Run Code Online (Sandbox Code Playgroud)