AttributeError: 'Worksheet' object has no attribute 'save'

Skip to first unread message

beatriz lopez

Jun 25, 2023, 6:50:24 PM6/25/23
to openpyxl-users

I've already import the LAST VERSION of openpyxl to use it in my Django project.
But I keep getting the same error:
AttributeError: 'Worksheet' object has no attribute 'save'
It's very strange because I have used this library in another python project using Jupiter Notebook but now using Spyder in a django project it doesn't work.
Could anyone help me please?

This is my django view:

class Report_FB(TemplateView):
    def get(self, request, *args, **kwargs):
        query = ficha_FB.objects.all()
        wb = Workbook()
        ws =
        ws['B1'] = 'REPORTE'
        ws['B3'] = 'MEDIDA'
        ws['C3'] = 'AÑO'
        ws['D3'] = 'PERIODO'
        ws['E3'] = 'CORREO'
        for q in query:
            ws.cell(row = cont, column = 3).value = q.año
            ws.cell(row = cont, column = 3).value = q.periodo
            ws.cell(row = cont, column = 3).value = q.correo
            cont +=1
        nombre_archivo = "Fuenlabrada_BienestarSocial.xlsx"
        response = HttpResponse(content_type = "application/ms-excel")
        contenido = "attachment; filename = {0}".format(nombre_archivo)
        response["Content-Disposition"] = contenido
        ws.template = False
        return response

Cuatro Jones

Jun 25, 2023, 7:35:50 PM6/25/23
It's been a while since I played around in Openpyxl, but if memory serves me correctly, the save method is tied to the 'Workbook' class, not the Worksheet class. 

You received this message because you are subscribed to the Google Groups "openpyxl-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web, visit

beatriz lopez

Jun 26, 2023, 2:15:12 AM6/26/23
to openpyxl-users
Thank you so much!
I have changed for and it worked! Thank u!

Cuatro Jones

Jun 26, 2023, 9:40:55 AM6/26/23
No problem, glad it worked out!

Reply all
Reply to author
0 new messages