Open
Conversation
martsberger
reviewed
Dec 11, 2019
| if rowspan > 1 or colspan > 1: | ||
| worksheet.merge_cells(start_row=row, start_column=column, | ||
| end_row=row + rowspan - 1, end_column=column + colspan - 1) | ||
| cell = worksheet.cell(row=row, column=column) |
Owner
There was a problem hiding this comment.
It looks like the error might have been here. What happens if we do column=column + colspan - 1 on this line instead of the other change?
Author
There was a problem hiding this comment.
column=column + colspan - 1 can't solve this error:
from tablepyxl import tablepyxl
table = """<table>
<tr>
<th colspan="2" rowspan="2">a1</th>
<th colspan="2">c1</th>
</tr>
<tr>
<td rowspan="2">c2</td>
<td>d2</td>
</tr>
<tr>
<td>a3</td>
<td>b3</td>
<td>d3</td>
</tr>
</table>"""
tablepyxl.document_to_xl(table, "test.xlsx")
# AttributeError: 'MergedCell' object has no attribute 'value'we can add this code before cell = worksheet.cell(row=row, column=column) to analyse this bug:
print(f'We think we are in row={row}, column={column},',
f'And now actually in {table_cell.value}, ', table_cell.element.attrib)We think we are in row=1, column=1, And now actually in a1, {'colspan': '2', 'rowspan': '2'}
We think we are in row=1, column=3, And now actually in c1, {'colspan': '2'}
We think we are in row=2, column=1, And now actually in c2, {'rowspan': '2'}
raise AttributeError: 'MergedCell' object has no attribute 'value'
In row=2, we think we are start from column=1, but actually A2 and B2 were already builded from "a1", so I judge MergedCell to skip them and shift to the actually column=3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

https://histudy.yuque.com/docs/share/2a1c0ca0-56bc-4735-ac0e-e2f142f4fb9f?#