Filling Excel cells using openpyxl
<p>in my new department i have to code with python and openpyxl. I have to fill cells of an excel sheet with test runs and the result(passed/failed).
This is all i got so far. I am not getting any errors but the sheet is still empty.. Any help would be nice. Thanks in advance. </p>

<pre><code>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')
</code></pre>

<p>If you are creating a new worksheet, it doesn't have any rows or columns, so <code>max_row</code> and <code>max_col</code> are 0, and your loop does nothing.  How many rows/columns to fill looks like it should be determined by the data (<code>tests</code>).</p>

python excel pycharm openpyxl