先从'A1'开始写入一行数据,使用黑体格式。然后再从开始写入一列数据,分别是A2 B2。
# Write a row of data starting from 'A1'
# with bold format .
worksheet.write_row('A1', headings, bold)
# Write a column of data starting from
# 'A2', 'B2' respectively .
worksheet.write_column('A2', data[0])
worksheet.write_column('B2', data[1])
# Create a chart object that can be added
# to a worksheet using add_chart() method.
# here we create a doughnut chart object .
chart2 =
workbook.add_chart({'type': 'doughnut'})
# Note use of alternative syntax to define ranges.
# = Sheet1 !$A$1 is equivalent to ['Sheet1', 0, 0].
# Configure the series and add user defined segment colors.
chart2.add_series({
'name': 'Doughnut sales data',
'categories': '= Sheet1 !$A$2:$A$4',
'values': '= Sheet1 !$B$2:$B$4',
'points': [
{'fill': {'color': '# FA58D0'}},
{'fill': {'color': '# 61210B'}},
{'fill': {'color': '# F5F6CE'}},
],
})
# Add a chart title
chart2.set_title({'name': 'Doughnut Chart with user defined colors'})
# add chart to the worksheet with an offset,
# at the top-left corner of a chart
# is anchored to cell C2 .
worksheet.insert_chart('C2', chart2, {'x_offset': 25, 'y_offset': 10})
# Finally, close the Excel file
# via the close() method.








暂无数据