[Django]-Django and xlrd, reading from memory

75👍

if form.is_valid():
    input_excel = request.FILES['input_excel']
    book = xlrd.open_workbook(file_contents=input_excel.read())

    # your work with workbook 'book'

    return render_to_response('import_excel.html', {'rows': rows})

When file_contents optional keyword is provided, filename keyword will not be used.

Happy Coding.

Leave a comment