Open, Edit and Save
Now that we are halfway into our project, let's practice a full pipeline with openpyxl! Here is our file "hello_world.xlsx":
Compito
Swipe to start coding
- Open the workbook called
"hello_world.xlsx"
; - Add
"Test text"
to the"C1"
cell; - Save the
workbook
.
Soluzione
from openpyxl import load_workbook
# Start by opening the spreadsheet and selecting the main sheet
workbook = load_workbook(filename="hello_world.xlsx")
sheet = workbook.active
# Write what you want into a specific cell
sheet["C1"] = "Test text"
# Save the spreadsheet
workbook.save(filename="hello_world_append.xlsx")
Here is "hello_world_append.xlsx" after successfully completing the task:
Mark tasks as Completed
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 1. Capitolo 7
AVAILABLE TO ULTIMATE ONLY