Advertisement
teslariu

openpy

Oct 18th, 2021
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import datetime
  5. from openpyxl import Workbook
  6.  
  7. # genero un libro
  8. libro = Workbook()
  9.  
  10. # creo una hoja
  11. hoja = libro.active
  12.  
  13. # Guardo el nro 42 en la celda A1 y bajo el cursor a A2
  14. hoja['A1'] = 42
  15.  
  16. # Agrego una lista: A2=1, B2=2, C2=3
  17. hoja.append([1, 2, 3])
  18.  
  19. # La fecha y hora se autoformatea
  20. hoja['A3'] = datetime.datetime.now()
  21.  
  22. # Guardo el archivo
  23. libro.save("LIBRO.xlsx")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement