Chart data cant handle " ' "

Issue #1190 resolved
Ростислав Місюра
created an issue

If we set sheet name with ' we'll not get DougnutChart

with that sheet name everything works

sheet.title = "some text"

if I add ' chart don't set data range

sheet.title = "some ' text"

python version 2.7.15rc1

Comments (7)

  1. CharlieC

    Please provide a complete example and any relevant errors.

    All sheet names containing apostrophes must be quoted. So some ' text becomes some ''text when serialised in references such as definedNames, formulae and charts.

  2. Ростислав Місюра reporter

    This code wont work, but with main_sheet.title = "Title" everything works fine.

    This text is in data range field of chart $'Tit''le'.$A$2:$A$5. It replace ' with '' but dont add data set.

    from openpyxl import Workbook
    from openpyxl.chart import DoughnutChart, Reference
    from datetime import datetime
    main_sheet_title = 'main_sheet_title'
    data = {
        'groups': [('group1', 3), ('group2', 6), ('group3', 4), ('group4', 11)],
    def generate_xlsx(, data=data):
        wb = Workbook()
        main_sheet =
        main_sheet.title = "Tit'le"
        for row in data['groups']:
        pie = DoughnutChart()
        labels = Reference(main_sheet, min_col=1, min_row=2, max_row=5)
        data = Reference(main_sheet, min_col=2, min_row=1, max_row=5)
        pie.add_data(data, titles_from_data=True)
        main_sheet.add_chart(pie, "D1")
    if __name__ == '__main__':
  3. Log in to comment