openpyxl.reader.excel module

Read an xlsx file into Python

class openpyxl.reader.excel.ExcelReader(fn, read_only=False, keep_vba=False, data_only=False, keep_links=True, rich_text=False)[source]

Bases: object

Read an Excel package and dispatch the contents to the relevant modules

read()[source]
read_chartsheet(sheet, rel)[source]
read_custom()[source]
read_manifest()[source]
read_properties()[source]
read_strings()[source]
read_theme()[source]
read_workbook()[source]
read_worksheets()[source]
openpyxl.reader.excel.load_workbook(filename, read_only=False, keep_vba=False, data_only=False, keep_links=True, rich_text=False)[source]

Open the given filename and return the workbook

Parameters:
  • filename (string or a file-like object open in binary mode c.f., zipfile.ZipFile) – the path to open or a file-like object

  • read_only (bool) – optimised for reading, content cannot be edited

  • keep_vba (bool) – preserve vba content (this does NOT mean you can use it)

  • data_only (bool) – controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet

  • keep_links (bool) – whether links to external workbooks should be preserved. The default is True

  • rich_text (bool) – if set to True openpyxl will preserve any rich text formatting in cells. The default is False

Return type:

openpyxl.workbook.Workbook

Note

When using lazy load, all worksheets will be openpyxl.worksheet.iter_worksheet.IterableWorksheet and the returned workbook will be read-only.