import xlsxwriter
import os
from datetime import datetime
file_path = 'C:/.../static/excel/'
if not os.path.exists(file_path):
os.makedirs(file_path)
workbook = xlsxwriter.Workbook(file_path+str(datetime.date(datetime.now()))+"test.xlsx")
worksheet = workbook.add_worksheet("test1")
worksheet.set_column('A:A', 20)
bold = workbook.add_format({
'bold': True})
worksheet.write('A1', 'Hello')
worksheet.write('A2', 'World', bold)
worksheet.write(2, 0, 123)
worksheet.write(3, 0, 123.456)
worksheet.write_column(4, 0, [1, 2, 3, 4])
worksheet.write_row(1, 1, [1, 2, 3, 4])
chart = workbook.add_chart({
'type': 'column'})
chart.add_series({
'values': ["test1",
4, 0, 7, 0
]})
worksheet.insert_chart('B3', chart)
workbook.close()