Advertisement
teslariu

excel

Nov 6th, 2021
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. from openpyxl import Workbook
  5.  
  6. # creo un libro de excel
  7. libro = Workbook()
  8.  
  9. # creo una hoja en el libro
  10. hoja1 = libro.active
  11.  
  12. # Guardo 42 en la celda A1, el cursor salta a A2
  13. hoja1['A1'] = 42
  14.  
  15. # Agrego los valores de una lista en forma horizontal (A2, B2, C2)
  16. hoja1.append([1, 2, 3])
  17.  
  18. # openpyxl formatea automáticamente la fecha y hora
  19. from datetime import datetime
  20. hoja1['A3'] = datetime.now()
  21.  
  22. # Grabo el archivo
  23. libro.save("sample.xlsx")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement