Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Open, Edit and Save | Openpyxl
Excel Automation with Python (project)

book
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

  1. Open the workbook called "hello_world.xlsx";
  2. Add "Test text" to the "C1" cell;
  3. Save the workbook.

Solución

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?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 7

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt