Home > Software design >  Python/Openpyxl: Merge empty row cells delimited by string
Python/Openpyxl: Merge empty row cells delimited by string

Time:01-26

I am trying to create a script using python and openpyxl to open up a given excel sheet and merge all cells in a given row together until the script finds a cell containing a string. The row placement is always the same, but the number of columns and the column placement of the strings is not so it needs to be dynamic. Once a new string is found, I want to continue to merge cells until the column that is right before the grand total. There are also cases where the cell doesn't need to be merged, because there is no empty cell in the data set to merge it with.

I found this answer Before

This is how I am trying to get it to look in the end: After

CodePudding user response:

To start, if you aren't familiar with openpyxl's merge and unmerge functions, I recommend your read about them in the documentation (enter image description here

AFTER :

enter image description here

  • Related