Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

read Excel files from Python

openpyxl

pip install openpyxl
python3
file_path='database-tables.xlsm'
sheet_name='Transaction Tables'

import openpyxl
xls=openpyxl.open(file_path)
# xls=openpyxl.load_workbook(file_path)
xls.worksheets
sheet=xls.get_sheet_by_name(sheet_name)
sheet.max_row
sheet.max_column

for row in sheet.iter_rows(min_row=1,
                           max_row=sheet.max_row,
                           min_col=1,
                           max_col=sheet.max_column):
    for cell in row:
        print(cell.value)

xlrd

pip install xlrd
python3
import xlrd
file_path='database-tables.xlsm'
# only for xls-files
xls=xlrd.open_workbook(file_path)

xlwings

pip install xlwings
python3
import xlwings
file_path='database-tables.xlsm'
dir(xlwings)
xls=xlwings.load(file_path)
dir(xls)