
Install Python from python.org, install OpenPyXL with pip, and install an Excel viewer such as Microsoft Excel or OpenOffice; start using OpenPyXL to automate Excel documents.
Always back up your workbooks when using OpenPyXL to prevent data loss, since there is no undo button, and errors can overwrite your original data.
Learn to create and open workbooks, add and remove sheets, rename them, access sheets by index or name, copy worksheets, and enumerate sheet titles with openpyxl.
Learn to read data from Excel cells using absolute and relative references, with examples like A1 and C2, then apply offset and read a full data range.
In this lecture, we are inserting and deleting rows and columns. Note that OpenPyXL has changed from a 0-based index to a 1-based index when inserting and deleting rows. The source code is updated to reflect these changes but the video shows the 0-based index usage.
Learn to move and copy cell ranges in openpyxl by offsetting ranges like A1:J10, moving cells, and duplicating values with iter_rows and worksheet cells.
Congratulations on reaching half the course. Post questions or comments in the discussion forum, offer feedback as a review, and continue studying.
Learn cell formatting in Excel, including color, font, size, and data formats, copy and merge cells, apply autofilter for sorting, use the fold method, and configure page setups for printing.
CORRECTION: In the video we are setting the old_cell font to
old_cell.font = Font(name='Arial', size=18, color=colors.RED).
Since then OpenPyXL has updated to not use the colors constants RED, BLUE etc.
Instead we have to write the colors as a HEX value. The code for red is "FF0000" and thus the new line becomes:
old_cell.font = Font(name="Arial", size=18, color="FF0000")
https://www.rapidtables.com/web/color/RGB_Color.html has a picker as well as a table for HEX colors.
Learn to merge and unmerge cells in OpenPyXL, using range borders like A1:B1 and A1:C4, and understand how merging preserves the upper-left value while discarding others.
Learn how to apply autofilter. Sorting cannot currently be done with OpenPyXL. I have attached the file 6.4_resources.py that contains the Win32 library that can apply the sort.
Learn to configure print page setups in openpyxl by applying paper size, orientation, and margins to sheets or workbooks, using page_setup options and predefined constants.
Create charts such as pie charts and bar charts, then place them on a chart sheet, and insert images into Excel using OpenPyXL.
Use tkinter file dialogs to open or save Excel workbooks with openPyXL, employing ask open file name and ask save as, and set the initial directory.
Learn to use pathlib to manage file paths and join the current working directory with file names. Retrieve files by extension with glob and open and read them in Python.
Time your Python scripts with the time module to measure OpenPyXL operations, using start and end timestamps. Observe how results vary with input size and avoid background processes.
Start Excel for viewing your work using Python and the os module to launch Excel.exe and open your workbook with OpenPyXL, such as 8.6_Open_me.xlsx, enabling editing and quick verification.
Take your finished course work into the real world by tackling a real-world Excel task and sharing feedback in the discussion forum to build confidence with more projects.
Requirements
Basic Python knowledge - Don't worry, we will cover each code snippet
You will need a computer with Python 3 installed, then we will cover how to install OpenPyXL
Some form of spreadsheet program. I use Excel, but you can also use OpenOffice or similar applications
Description
Become an Excel Power User - Learn how to control & automate Excel with Python and OpenPyXL
Do you have a bunch of Excel files that you need to format or put some value in a cell on each page? Do you need to create Charts on your spreadsheets or insert formulas? Maybe you just want to show off at the office! Whatever your needs, you can expect a comprehensive guide going through the nuts and bolts of how automating Excel works. The course dives straight into OpenPyXL, so you will be up and running creating and manipulating spreadsheets in no-time.
I have had so much use of OpenPyXL when dealing with spreadsheets. You can create advanced sorts and filters, insert and delete rows, copy cells, set custom formatting and much more. I even got a job based on my OpenPyXL knowledge. I am sure you will benefit from learning OpenPyXL if you have even the slightest interest in making your everyday life easier.
After taking this course you will:
Know how to create and manipulate Workbooks and Sheets
Read cell data with absolute and relative references
Iterate over cells and perform actions on each cell
Know how to delete rows and columns
Insert formulas and tables
Format your spreadsheets with fonts, colors and cell types
Understand how you could apply this knowledge to your own work
Create files and folders
Interact with open and save file dialogs
Whether it's gaming, business, engineering, or data you're passionate about, this course will give you everything you need for working on spreadsheets with Python. Take this course today, and begin your journey to having a full-fledged career as an Excel Power User!
Who this course is for:
Anyone interested in controlling and automating Excel with Python - with or without coding experience. People who want to get rid of manually editing hundreds of spreadsheets by hand
Especially suitable for those who would like to extract or add data on multiple spreadsheets or automate the creation of spreadsheets from input data
People who would like to know more about solving Excel problems with Python
People who would like to start consulting services by automating Excel tasks