Advertisement
teslariu

excel

Jan 22nd, 2022
1,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # instalar openpyxl: python -m pip install openpyxl
  5.  
  6. # Script que calcula el perimetro y la superficie de un rectángulo
  7.  
  8. from openpyxl import Workbook
  9.  
  10. # creo un libro de Excel
  11. libro = Workbook()
  12.  
  13. # activo el libro y le creo una hoja
  14. hoja = libro.active
  15.  
  16. # Añado datos a una celda
  17. hoja['A1'] = 42
  18.  
  19. # Agrego una lista de datos
  20. hoja.append([1, 2, 3])
  21.  
  22. # Python types will automatically be converted
  23. import datetime
  24. hoja['A3'] = datetime.datetime.now()
  25.  
  26. # Grabo el archivo
  27. libro.save("sample.xlsx")
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement