0

I'm using openpyxl (unfortunately I don't know how to find out my version number, installed it about a month ago) on Windows with python 2.7 and want to copy a worksheet that I generated using a template.xlsx file to a new workbook. The template has a single worksheet that I alter. I want to load it n times and copy each version as a new worksheet to another workbook. Could also be the same workbook ifneedbe.

I found some hints here which took me here. The example doesn't work as it seems the add_sheet() method has been removed.

primary.add_sheet(copy.deepcopy(ws),ido+1)
AttributeError: 'Workbook' object has no attribute 'add_sheet'

Also couldn't find anything helpful in the API.

Community
  • 1
  • 1
Dominic
  • 253
  • 1
  • 2
  • 14
  • Possible duplicate of [Copy whole worksheet with openpyxl](http://stackoverflow.com/questions/27101024/copy-whole-worksheet-with-openpyxl) – John Y Jan 20 '16 at 19:05

1 Answers1

0

I'm afraid copying worksheets is not supported because it is far from easy to do.

Charlie Clark
  • 16,505
  • 4
  • 43
  • 49
  • That's unfortunate... do you probably know about another package that could do it? Could you point me to a place where it's described why it is so difficult to copy a worksheet as I can easily create an empy one? – Dominic Jan 15 '16 at 10:49
  • There s no easy way. See https://bitbucket.org/openpyxl/openpyxl/issues/171/copy-worksheet-function for some more information. – Charlie Clark Jan 15 '16 at 11:42