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":
Tarea
Swipe to start coding
- Open the workbook called
"hello_world.xlsx"
; - Add
"Test text"
to the"C1"
cell; - Save the
workbook
.
Solución
99
1
2
3
4
5
6
7
8
9
10
11
12
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
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 7
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla