While using Worksheet.insert_rows, Worksheet.insert_cols (and other ones that rely on Worksheet_move_cell) there is an issue with handling cells with row-wide/column-wide styles.
The contents of the cells are correctly transferred one row below. However, the old row-wide styles for the rows have been completely ignored and have not been cleaned up correctly.
Comments
The above demonstration uses insert_rows which uses _move_cell to move the cells, so the problem is with _move_cell (and other functions that rely on it).
In a sense, _move_cell "does" its job, because it naively moves the passed cells and their styles. If we modify the above code, we will notice that the cell whose style should be cleared is (not) actually cleared:
While using
Worksheet.insert_rows
,Worksheet.insert_cols
(and other ones that rely onWorksheet_move_cell
) there is an issue with handling cells with row-wide/column-wide styles.Code example
Environment
Input
test_in.xlsx
filetest_in.xlsx
Sample file with three lines of content.
Expected output
Every line of content with their styles is moved by one row down.
Actual output
test_out.xlsx
test_out.xlsx
The contents of the cells are correctly transferred one row below. However, the old row-wide styles for the rows have been completely ignored and have not been cleaned up correctly.
Comments
insert_rows
which uses_move_cell
to move the cells, so the problem is with_move_cell
(and other functions that rely on it)._move_cell
"does" its job, because it naively moves the passed cells and their styles. If we modify the above code, we will notice that the cell whose style should be cleared is (not) actually cleared:Output:
I assume there must be some "global row" and "global column" properties that
_move_cell
doesn't take into account. I didn't invest it further.