This is a session to practice controlling Excel files with Python. The session contains:
- importing specific parts of the
openpyxl
module, - loading an Excel workbook with the
load_workbook
function, - accessing the active sheet in the file with
<workbook>.active
, - reading and writing to a workbook by accessing specific cells,
- writing to a workbook using the
<worksheet>.append
method, - saving the workbook,
- retrieving all the sheet names,
- accessing a specific sheet, instead of an active sheet,
- creating a new sheet,
- creating a new workbook,
- giving a name to the active sheet,
- accessing specific columns in a sheet with the help of the
get_column_letter
function, - merging and unmerging cells,
- insert and deleting rows and columns,
- cutting and pasting cells,
- controlling the styling in a sheet,
- finally, taking data from a python dictionary and writing them to a new Excel file.
Here is the OpenPyXl documentation to get more information about various methods of working with an Excel file using Python.
The session could be coded along following this link, although my code and file is a bit different:
Automate Excel With Python - Python Excel Tutorial (OpenPyXL)