Hi,
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 = wb.active
ws['B1'] = 'REPORTE'
ws.merge_cells('B1:E1')
ws['B3'] = 'MEDIDA'
ws['C3'] = 'AÑO'
ws['D3'] = 'PERIODO'
ws['E3'] = 'CORREO'
cont=4
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
ws.save(response)
return response