Blank workbook file gives me `We found a problem with some content` error

Issue #1225 resolved
Ilya Levin
created an issue

from openpyxl import Workbook
wb = Workbook()
wb.save("/Users/work/Downloads/temp.xlsx")

This code is so simple, why would I get We found a problem with some content error when I open the file?

I'm using Microsoft Excel for Mac version 16

Comments (7)

  1. CharlieC

    I'm not sure why this is happening because I use MacOS myself but the manifest contains an exta and erroneous definition. Can you try the following:

    from openpyxl.packaging.manifest import Manifest
    mf = Manifest()
    mf.Default
    

    You should see the following:

    [<openpyxl.packaging.manifest.FileExtension object>
    Parameters:
    Extension='rels', ContentType='application/vnd.openxmlformats-package.relationships+xml',
     <openpyxl.packaging.manifest.FileExtension object>
    Parameters:
    Extension='xml', ContentType='application/xml']
    
  2. Ilya Levin reporter

    Seems like I get the same result. Any other reason why this be broken?

    [<openpyxl.packaging.manifest.FileExtension object>
    Parameters:
    Extension='rels', ContentType='application/vnd.openxmlformats-package.relationships+xml', <openpyxl.packaging.manifest.FileExtension object>
    Parameters:
    Extension='xml', ContentType='application/xml']
    

    Thanks for your help on this!

  3. CharlieC

    Not really. In the your XLSX manifest you have an extra line <Default ContentType="text/xml" Extension="xml"/> and this is what Excel doesn't like.

    Do you have anything running that is using the Python mimetypes database? If so you could try a checkout of the 2.6 branch which coincidentally contains a change regarding this.

  4. Ilya Levin reporter

    So I removed the extra line that you mentioned and re-zipped the file, but still got the same error. Perhaps there's more than one file that's messed up? See attached above.

  5. CharlieC

    No, the problem is because you zipped the file using Finder so MacOS added all kinds of junk that Excel objects too. You need to drop into the folder you create and use zip manually in the Terminal / iTerm.

    I normally handle files like this:

    unzip -d 1225 Issues/bug1225.xlsx
    mate 1225
    # … edit the files in TextMate
    cd 1225
    zip ../1225-fixed.xlsx -r * && open ../1225-fixed.xlsx
    

    But as I said, something on your system has set the default mimetype for XML to text/xml and that needs fixing.

  6. Log in to comment