Skip to content

AttributeError: 'MergedCell' object attribute 'value' is read-only #25

@kitqee

Description

@kitqee
Is it possible to make such a table?

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    table {
      border-collapse: collapse;
    }

    table, th, td {
      border: 1px solid black;
    }

    th, td {
      padding: 8px;
      text-align: left;
    }
  </style>
</head>
<body>

<table>
  <tr>
    <th rowspan="2">Name</th>
    <th rowspan="2">Measure</th>
    <th colspan="3">Plan</th>
    <th colspan="3">Fact</th>
    <th rowspan="2">%</th>
  </tr>
  <tr>
    <th>Volume</th>
    <th>Price</th>
    <th>Total price</th>
    <th>Volume</th>
    <th>Price</th>
    <th>Total price</th>
  </tr>
  <tr>
    <th colspan="9">Section</th>
  </tr>
  <tr>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
  </tr>
  <tr>
    <th colspan="9">Subsection</th>
  </tr>
  <tr>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
    <td>value</td>
  </tr>
</table>

</body>
</html>
Now I get this error:
Traceback (most recent call last):
  File "/home/aesfur/workspace/osla-api/src/apps/building/__init__.py", line 27, in <module>
    tablepyxl.document_to_xl(table, 'data.xlsx')
  File "/home/aesfur/workspace/venv/osla/lib/python3.6/site-packages/tablepyxl/tablepyxl.py", line 96, in document_to_xl
    wb = document_to_workbook(doc, base_url=base_url)
  File "/home/aesfur/workspace/venv/osla/lib/python3.6/site-packages/tablepyxl/tablepyxl.py", line 86, in document_to_workbook
    table_to_sheet(table, wb)
  File "/home/aesfur/workspace/venv/osla/lib/python3.6/site-packages/tablepyxl/tablepyxl.py", line 68, in table_to_sheet
    insert_table(table, ws, 1, 1)
  File "/home/aesfur/workspace/venv/osla/lib/python3.6/site-packages/tablepyxl/tablepyxl.py", line 104, in insert_table
    row = write_rows(worksheet, table.body, row, column)
  File "/home/aesfur/workspace/venv/osla/lib/python3.6/site-packages/tablepyxl/tablepyxl.py", line 41, in write_rows
    cell.value = table_cell.value
AttributeError: 'MergedCell' object attribute 'value' is read-only

Process finished with exit code 1

openpyxl 3.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions