Is it possible to assign an Excel Chart Object name to a chart I am creating with XlsxWriter?
Thanks
Advertisement
Answer
It is (unintentionally) undocumented but you can set the object name for a chart when you create it. Like this:
import xlsxwriter workbook = xlsxwriter.Workbook('chart.xlsx') worksheet = workbook.add_worksheet() # Create a new Chart object. chart = workbook.add_chart({'type': 'column', 'name': 'MyChart'}) # Setting the name. worksheet.write_row('A1', [1, 2, 3, 2, 1]) # Configure the chart. chart.add_series({'values': '=Sheet1!$A$1:$E$1'}) # Insert the chart into the worksheet. worksheet.insert_chart('A3', chart) workbook.close()
Output:
Update: It is documented now.