1. openpyxl
  2. openpyxl
  3. openpyxl
  4. Issues

Issues

Issue #209 resolved

sheets are out of order

Mark Mikofski
created an issue

expected: load sheets by name, they should correspond to the named sheets in the file

observed: unfortunately, the sheet names are unreliable, The order in which they are listed is the same as the actual workbook, but the names are mixed up. IE: the first sheet in the book is still the first sheet in the array, but it's name may or not be the same, so that using get_sheet_by_name, may not work.

It seems that if the workbook has charts as sheets, then there names will get loaded.

EG

'work' has sheet1: 'hello' sheet2: 'graph1' (a chart) sheet3: 'bye'

>>> wb = load_workbook('work')
>>> wb.get_sheet_names()
['hello', 'graph1', 'bye']

see the problem!

Comments (6)

  1. Eric Gazoni

    fixes issue #165, #179 and #209

    • add function read_content_types to openpyxl/reader/workbook.py that reads all of the 'Override' items in [Content_Types].xml
    • import ARC_CONTENT_TYPES and read_content_types into openpyxl/reader/excel.py
    • create constants VALID_CHARTSHEET and VALID_WORKSHEET that have the ContentType tag specified in [Content_Types].xml for chartsheets and worksheets
    • call read_content_types immediately before read_sheet_titles
    • before iterating over sheet_names create new list called worksheet_names that contains only the list of sheets that are actually worksheets, by comparing their type to VALID_WORKSHEET
    • import basic debug logging, use standard message format (from Doug Hellmann) "http://doughellmann.com/2007/05/pymotw-logging.html"
    • add show_debug_log optional arg to load_workbook & pass it on to Lload_workbook
    • add Sphinx autodoc text for show_debug_log
    • if show_debug_log, then output name of each worksheet before it's loaded

    → <<cset 498594f25594>>

  2. Log in to comment