Error when loading a workbook

Issue #1162 resolved
Francis W created an issue

import openpyxl openpyxl.load_workbook('Sprint qualité v. 0.3.xlsx')

...

ValueError: Table names cannot have spaces

openpyxl._version_

'2.5.12'

Comments (5)

  1. CharlieC

    Thanks for the report and the file. This is an odd one because the specification defines two different name attributes for tables, the name and the displayName. The specification then says about the displayName

    This name shall not have any spaces in it, and it shall be unique amongst all other displayNames and definedNamesintheworkbook.

    It then says about the name

    It has the same length and character restrictions as for displayName. By default this should be the same as the table's displayName. This name should also be kept in synch with the displayName

    But in your file we have this:

    <x:table id="1" name="Historique des modifications du" displayName="Historique_des_modifications_du" ref="A1:D3" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
      <x:tableColumns count="4">
        <x:tableColumn id="1" name="Modification" />
        <x:tableColumn id="2" name="Date" />
        <x:tableColumn id="3" name="Auteur" />
        <x:tableColumn id="4" name="Remarques" />
      </x:tableColumns>
      <x:tableStyleInfo name="Historique des modifications du-style" showFirstColumn="1" showLastColumn="1" showRowStripes="1" showColumnStripes="0" />
    </x:table>
    

    Where the name has spaces but the displayName doesn't. Now, while I think the specification here is possibly flawed — there is little point in enforcing no spaces in the name visible to users but not in the technical name — I'm not sure how best to handle it apart from renaming the table.

  2. Francis W reporter

    Hello, Thank you for your deep analysis. In fact, I collected this file from a workshop. As I am testing a process for analysis Excel files I tested with different files and I got sticked with this one which I reported. But if this is an exceptionnal issue, it may not be worth dealing with it. BTW, xlrd could load it. Best regards, Francis

  3. CharlieC

    xlrd doesn't read anything like as much of the file as openpyxl does. A lot of people use named tables a lot in their files and appreciate it when they don't get lost.

    This is fairly easy to fix but I will want to check with the OOXML Working Group first.

  4. Log in to comment