How to show excel workbook in the django web application before downloading?
I want to display excel sheet in web application (in the same format like pdf or any other format) before downloading.AS per my current code, excel sheet is downloading to my system.
code:
from io import BytesIO as IO
import xlsxwriter
from django.http import HttpResponse
def export_page(request):
excel_file = IO()
workbook = xlsxwriter.Workbook(excel_file, {'in_memory': True})
worksheet = workbook.add_worksheet()
worksheet.write('A1', 'Some Data')
workbook.close()
excel_file.seek(0)
response = HttpResponse(excel_file.read(),
content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
response['Content-Disposition'] = 'attachment; filename="Report.xlsx"'
return response
Can anyone suggest a solution to show the excel sheet in web page using Django?