So, why am i writing on this when you can just read about it in the openpyxl docs
There’s no such thing in the docs and i had spent a lot of time trying to figure how to duplicate a table from one sheet to the other and maintaining both differently.
To make things clearer,
i should explain exactly what i was trying to do and why i needed to make copy of tables from one spreadsheet to the other.
But first, Do you even know what is openpyxl, i guess yes, if not you wouldn’t bother reading this post.
Openpyxl is a python library to read and write excel files.
It let’s you perform a variety of operations on files like XLSX including styling.
So going back to why i needed to copy tables accross spreadsheet.
The script i’m working on creates spreadsheet on the fly as it scrapes data off from some website.
The script is not creating the structure of the spreadsheet from scratch, there’s a default spreadsheet called ‘Template‘ which the other spreadsheet are based on.
Now the problem is that while duplicating the “template” sheet, the table isn’t getting duplicated along to the new sheet.
And, i really needed the table to get copied along to the other sheet as it contains a lot of formular in use.
It’s not feasible and possible for the script to create the tables, it’s formula and attribute as it creates the new sheet.
So, in summary, the table must be copied along to the new sheet.
Enough of my story, let’s get to it