Possible bug in Excel importer / doesnt't play nicely with R openxlsx::write.xlsx()

OS (e.g. Mac OS 10.14):
PsychoPy version (e.g. 2022.2.5):
**Standard Standalone? y
**What are you trying to achieve?:
Control an outer loop

**What did you try to make it work?:
Trying to attach an Excel file to control the loop. The Excel file was written by R package openxlsx using openxlsx:write.xlsx(). My workaround for now is using a csv file, which works fine. Interestingly, an Excel file for inner loop control also written using openxlsx::write.xlsx() works fine.

What specifically went wrong when you tried that?:
I got an error message Something went wrong…please report to the developers, which I’m doing with this post. I’m attaching the excel file at the bottom in case it helps debugging.

Traceback (most recent call last):
File „/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/builder/dialogs/init.py“, line 1531, in onBrowseTrialsFile
File „/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/data/utils.py“, line 356, in importConditions
File „/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/openpyxl/reader/excel.py“, line 315, in load_workbook
File „/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/openpyxl/reader/excel.py“, line 280, in read
File „/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/openpyxl/reader/excel.py“, line 255, in read_worksheets
File „/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/openpyxl/reader/drawings.py“, line 24, in find_images
File „zipfile.pyc“, line 1475, in read
File „zipfile.pyc“, line 1514, in open
File „zipfile.pyc“, line 1441, in getinfo
KeyError: „There is no item named ‚xl/drawings/drawing1.xml‘ in the archive“

Exp4_blocks_1.xlsx (6.4 KB)

Ultimately, this isn’t something we can fix - it’s a bug either in R openxlsx writer or in openpyxl rather than in any of the psychopy code. It needs fixing in one of those packages

From the error message my guess is that there’s supposed to be a drawing in that file? When I open in excel I don’t see one though so maybe it’s the writing of the file, referring to a drawing that doesn’t exist, that’s the problem?

Thanks, Jon. I never put anything resembling a drawing or a string that contains drawing in that file. But looking at the unzipped excel file (I just remembered that they are just zip files), I found the following in [Content_Types.xml]:

ContentType=“application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml”/><Override PartName=“/xl/drawings/drawing1.xml”

But indeed the archive did not contain the referenced file drawing1.xml or even the drawing directory in the xl subdirectory. So I guess it might be a bug in openxlsx, I will try my luck there.

I’ve reported it here: https://github.com/ycphs/openxlsx/issues/429