Skip to content

Instantly share code, notes, and snippets.

@TonyDiana
Forked from inazense/LectorXLSX.py
Created February 20, 2021 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TonyDiana/d42fce464b0dbf00cdf17ccff3362695 to your computer and use it in GitHub Desktop.
Save TonyDiana/d42fce464b0dbf00cdf17ccff3362695 to your computer and use it in GitHub Desktop.
Lector ficheros XLSX con Python3
# -*- coding: utf-8 -*-
from openpyxl import load_workbook # Requiere instalar openpyxl
import os.path
rutaXLSX = "fichero.xlsx"
if os.path.isfile(rutaXLSX):
libro = load_workbook(rutaXLSX) # Abro el excel para extraer los campos
hoja = libro.get_sheet_by_name(libro.get_sheet_names()[0]) # Cojo la primera hoja
for fila in hoja.rows:
for celda in fila:
print(celda.value)
else:
print("No se ha reconocido el fichero")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment