0
我必須使用python和openpyxl進行編碼。我必須用測試運行和結果(通過/失敗)填寫Excel單元格的單元格。 這就是我到目前爲止所得到的。我沒有得到任何錯誤,但工作表仍然是空的..任何幫助將是很好的。提前致謝。在我的新部門使用openpyxl填充Excel單元格
def create_report(self, root, now):
tests = (
['Discover DTC time', 'failed'],
['Drucksensor_DTC_Startup', 'failed'],
['Drucksensor_DTC_Runtime', 'passed'],
)
wb = xl.Workbook()
ws = wb.active
ws.title = 'ExcelSummaryReport.xlsx'
row = 1
col = 0
for i in range(row, ws.max_row):
for j in range(col, ws.max_col):
ws.cell(row=i + 1, col=j).value = tests[i]
wb.save('ExcelSummaryReport.xlsx')
這與pycharm有什麼關係? –
我正在使用的ide是pycharm –
'ws.max_row'和'ws.max_col'確實不應該這樣使用。只是循環你的測試結果和'ws.append()' –