Skip to content

Can't get XLSX support working #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
KnowYourselves opened this issue Feb 22, 2021 · 4 comments
Closed

Can't get XLSX support working #68

KnowYourselves opened this issue Feb 22, 2021 · 4 comments

Comments

@KnowYourselves
Copy link

KnowYourselves commented Feb 22, 2021

Hello!

Since XLRD dropped XLSX support I've been unable to get support for this type of file working.

I have the following form:

class UploadFileForm(forms.Form):
    """
    Form to upload bank movements csv/xls/xlsx file
    """

    file = forms.FileField(
        validators=[FileExtensionValidator(['xls', 'xlsx', 'csv'])],
    )

I also have a form view that gives the error XLRD Error: Excel xlsx file; not supported when the following code is run in the form_valid function:

movements_data = form.cleaned_data['file'].get_array()

I've tried a variety of things so it doesn't use XLRD but nothing seems to work. I followed the documentation and installed pyexcel-xls and pyexcel-xlsx. I also tried importing pyexcel.ext.xlsx both on the view and the form file to no avail.

Any surefire way to get XLSX support working again?

Thanks!

EDIT: I have found that the library kwarg lets me bypass XLRD and use pyexcel-xlsx directly, but wouldn't this break support for csv, xls, and others?

@chfw
Copy link
Member

chfw commented Feb 22, 2021

please install latest pyexcel-xls, which has pinned on older version of xlrd.

@chfw
Copy link
Member

chfw commented Feb 22, 2021

EDIT: I have found that the library kwarg lets me bypass XLRD and use pyexcel-xlsx directly, but wouldn't this break support for csv, xls, and others?

with 'library' parameter, it assumes that you explicitly know the file type so you can choose the pyexcel plugin. but I hope you will not force pyexcel-xlsx to read a csv file :)

@chfw
Copy link
Member

chfw commented Feb 22, 2021

pyexcel/pyexcel-xls#41

@KnowYourselves
Copy link
Author

Thx! I did install it, but it didn't work. In the end, I deleted all the packages, cleaned the cache, installed them again, and now it's working like a charm. Thx for the response!

@chfw chfw closed this as completed Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants