Openpyxl insert_rows; Mismatch of content and format

I have a excel file with a worksheet. I want to insert a new row in 6th row. If I directly open Excel app and press the right-click the mouse on 6th row and press “insert”, it will insert a new row while doesn’t mismatch the format and content below the 6th row.

worksheet.insert_rows(idx=6, amount=1)

However, if I use the above code to insert a new row, the content below the 6th row will be pan to the next row, but the format remains unchanged.
For example, I have a merged cell in 9th row. I hope that its format and content will be synchronously pan to the 10th row after insertion. But after I run the code, the content was pan to 10th row, but the merged cell format still remains at 9th row.
How can I modify my code to meet my need? Thanks very much!!! qwq

Unfortunately, I think you’ll need to explicitly update all of the formats below the inserted row. If you don’t already know what the formats need to be, you could loop through the rows from last_row to the row you inserted, and update the formats to copy the row above it.

What I generally do with openpyxl is generate all of the data in a worksheet, then apply all of the formatting at the end.