Figure 12-1. Screenshot of workbook in Excel
xlsxwriter has many more options to generate Workbook objects, for example with
charts. Consider the following code (cf. the xlsxwriter documentation):
In [ 18 ]: wb = xlsxwriter.Workbook(path + ‘chart.xlsx’)
ws = wb.add_worksheet()# write cumsum of random values in first column
values = np.random.standard_normal( 15 ).cumsum()
ws.write_column(‘A1’, values)# create a new chart object
chart = wb.add_chart({‘type’: ‘line’})# add a series to the chart
chart.add_series({‘values’: ‘=Sheet1!$A$1:$A$15’,
‘marker’: {‘type’: ‘diamond’},})
# series with markers (here: diamond)# insert the chart
ws.insert_chart(‘C1’, chart)wb.close()