Charts not created correctly when worksheet should be quoted

Issue #954 resolved
Johan Paduart created an issue

When running the code below, the chart reference to the worksheet with a "%" in the sheet name, does not appear. Similar to https://bitbucket.org/openpyxl/openpyxl/issues/788 (sheet reference should be quoted)

import openpyxl
from openpyxl.chart import LineChart, Reference, Series

wb = openpyxl.Workbook()
ws1 = wb.create_sheet("SheetWith%", 0)
ws2 = wb.create_sheet("SheetWithout", 0)
ws3 = wb.create_sheet("Graph")

lc = LineChart()

data = Reference(ws1, min_col = 1, min_row = 24, max_col = 1, max_row = 64)
series = Series(data, title = "With%")
lc.append(series)

data = Reference(ws2, min_col = 1, min_row = 24, max_col = 1, max_row = 64)
series = Series(data, title = "Without%")
lc.append(series)

ws3.add_chart(lc, "A1")
wb.save('test.xlsx')

Comments (4)

  1. CharlieC

    Escaping is fortunately handled in a single place.

    According to 18.17.2.3 in the specification % doesn't need quoting. But the specification appears to be incorrect here, at least as far as Excel is concerned. I have an open bug with the WG on this.

  2. Log in to comment