Error when reading LabView-created Excel file

1,402 views
Skip to first unread message

Duane Kaufman

unread,
Dec 18, 2017, 4:44:46 PM12/18/17
to openpyxl-users
Hello,

I have an Excel file (20171206100734.xlsx, attached), which is generated with LabVIEW 14.0.1f10, which I would like to read with openpyxl.

I am running Python 3.4 with openpyxl 2.4.9 (Windows 10 64bit)

The following code crashes with:

Traceback (most recent call last):
  File "c:\Python34\lib\site-packages\openpyxl\descriptors\base.py", line 57, in _convert
    value = expected_type(value)
TypeError: object() takes no parameters

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 19, in <module>
    ReadRawFile()
  File "test.py", line 9, in ReadRawFile
    wb = load_workbook(filename = r'./20171206100734.xlsx', read_only=True, data_only=True)
  File "c:\Python34\lib\site-packages\openpyxl\reader\excel.py", line 221, in load_workbook
    apply_stylesheet(archive, wb) # bind styles to workbook
  File "c:\Python34\lib\site-packages\openpyxl\styles\stylesheet.py", line 182, in apply_stylesheet
    stylesheet = Stylesheet.from_tree(node)
  File "c:\Python34\lib\site-packages\openpyxl\styles\stylesheet.py", line 99, in from_tree
    return super(Stylesheet, cls).from_tree(node)
  File "c:\Python34\lib\site-packages\openpyxl\descriptors\serialisable.py", line 92, in from_tree
    return cls(**attrib)
  File "c:\Python34\lib\site-packages\openpyxl\styles\stylesheet.py", line 70, in __init__
    self.fills = fills
  File "c:\Python34\lib\site-packages\openpyxl\descriptors\sequence.py", line 27, in __set__
    seq = [_convert(self.expected_type, value) for value in seq]
  File "c:\Python34\lib\site-packages\openpyxl\descriptors\sequence.py", line 27, in <listcomp>
    seq = [_convert(self.expected_type, value) for value in seq]
  File "c:\Python34\lib\site-packages\openpyxl\descriptors\base.py", line 59, in _convert
    raise TypeError('expected ' + str(expected_type))
TypeError: expected <class 'openpyxl.styles.fills.Fill'>

Code:
def ReadRawFile():
    from openpyxl import load_workbook
    import os
    
    dirpath = os.getcwd()

    # read in file in read-only mode to limit memory consumption
    wb = load_workbook(filename = r'./20171206100734.xlsx', read_only=True, data_only=True)
    ws = wb.active

    for row in ws.rows:
        for cell in row:
            print(cell.value)
        break

if __name__ == "__main__":
    # execute only if run as a script
    ReadRawFile()

Any ideas or work-arounds would be appreciated.

Thanks,
Duane
20171206100734.xlsx

Charlie Clark

unread,
Dec 19, 2017, 6:16:44 AM12/19/17
to openpyx...@googlegroups.com
Am .12.2017, 22:44 Uhr, schrieb Duane Kaufman <duane....@gmail.com>:

> Any ideas or work-arounds would be appreciated.

The file is broken because it contains an invalid fill element. See
https://bitbucket.org/openpyxl/openpyxl/issues/913 for a discussion of
precisely this problem.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226

Duane Kaufman

unread,
Dec 19, 2017, 12:27:21 PM12/19/17
to openpyxl-users
On Tuesday, December 19, 2017 at 5:16:44 AM UTC-6, Charlie Clark wrote:
Am .12.2017, 22:44 Uhr, schrieb Duane Kaufman <duane....@gmail.com>:

> Any ideas or work-arounds would be appreciated.

The file is broken because it contains an invalid fill element. See  
https://bitbucket.org/openpyxl/openpyxl/issues/913 for a discussion of  
precisely this problem.

Charlie
--

I had searched for a similar problem to mine, but missed this.

Thanks for the pointer.

Sincerely,
Duane

Rajiv Daxini

unread,
Nov 6, 2021, 11:44:08 AM11/6/21
to openpyxl-users
hello,

The bitbucket link no longer works. After logging in, the page is empty. Can I get some info on how to resolve this, please? I am using LabVIEW for DAQ and generating many thousands of xlsx files, which I then need to import into python for data analysis.

Thank you

Zhenyu Liu

unread,
Aug 23, 2022, 10:57:21 AM8/23/22
to openpyxl-users
Hi,

Got exact the same problem here. After spending an afternoon searching around, it turns out this problem is raised by openpyxl but may has nothing to do with it. 
You are getting this error as the stylesheet of the excel file you are trying to open is corrupted. For my case, I downloaded it from the company's internal netdisk which messes with every file's format(including word etc.)

Looking closer in the stack trace, openpyxl is trying to initialising the stylesheet where some of the node is 'None' and it tries to wrap it with a Type and failed.

Reformat the file works, or you can simple erase all format and save. For my case is tricker which I can't manually do that to 70 files and this problems seems to happen when load the workbook, there's no other frameworks that can clean the format without correctly initializing the stylesheet...

Anyway, good luck!

Reply all
Reply to author
Forward
0 new messages