teslariu

excel

Feb 6th, 2021
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. #
  3. from openpyxl import Workbook
  4.  
  5. # crear el libro de excel en la variable libro
  6. libro = Workbook()
  7.  
  8. # activamos el libro para crear automaticamente hojas
  9. hoja1 = libro.active
  10.  
  11. # titulo de la hoja
  12. hoja1.title = "HOJITA  1"
  13.  
  14. # aƱadimos contenido
  15. hoja1["A1"] = 3.1416
  16. hoja1["B14"] = "HOLA A TODOS"
  17. hoja1["F8"] = "Dentro de F8"
  18.  
  19. # creo otras hojas
  20. hoja2 = libro.create_sheet("HOJA DOS")
  21. hoja3 = libro.create_sheet("TERCERA HOJA")
  22.  
  23. # grabo el archivo
  24. libro.save(filename="ARCHIVO_PYTHON.xlsx")
  25.  
Advertisement
Add Comment
Please, Sign In to add comment