theorchard / openpyxl

Other
54 stars 21 forks source link

`Worksheet._move_cell` issue with handling row-wide/column-wide styles #44

Closed dsonyy closed 8 months ago

dsonyy commented 8 months ago

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.

Code example

import openpyxl as pxl

workbook = pxl.load_workbook('test_in.xlsx')
worksheet = workbook.active

worksheet.insert_rows(1, 1)

workbook.save('test_out.xlsx')

Environment

Input test_in.xlsx file

test_in.xlsx

Sample file with three lines of content.

image

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. image

Comments

dsonyy commented 8 months ago

just realized openpyxl is using this source https://foss.heptapod.net/openpyxl/openpyxl

Reposted issue: https://foss.heptapod.net/openpyxl/openpyxl/-/issues/2144