Can't copy worksheet with merged cells

Issue #1215 duplicate
Brandon Booth created an issue

I have an excel file with multiple worksheets. I'm trying to copy a sheet with merged cells and I get an error.

My code:

pg = openpyxl.load_workbook("test.xlsx")
ws = pg.copy_worksheet(pg["sheet1"])

The error:

Traceback (most recent call last):

  File "<ipython-input-41-a49f299a8c1f>", line 1, in <module>
    ws = pg.copy_worksheet(pg["sheet1"])

  File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\workbook\workbook.py", line 394, in copy_worksheet
    cp.copy_worksheet()

  File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\worksheet\copier.py", line 43, in copy_worksheet
    self.target.merged_cells = copy(self.source.merged_cells)

  File "C:\ProgramData\Anaconda3\lib\copy.py", line 88, in copy
    return copier(x)

  File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\worksheet\cell_range.py", line 456, in __copy__
    n.ranges.append(copy(r))

  File "C:\ProgramData\Anaconda3\lib\copy.py", line 88, in copy
    return copier(x)

  File "C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\worksheet\cell_range.py", line 136, in __copy__
    title=self.title)

TypeError: __init__() got an unexpected keyword argument 'min_col'

Comments (1)

  1. Log in to comment