Nov-14-2018, 08:00 PM
Hello,
I am using openpyxl to plot some data in Excel. However, there can sometimes be more than 256 series which is the maximum limit in Excel.
I am able to create a single plot of up to 256 series, but I am unable to make a new plot if I need to make more plots.
So far, what I have done:
-determined the where the data starts and stops
-calculate how many charts I need
-create a dictionary of different charts
-once I reach 256 series, I want to insert that chart and start updating the next chart
I am using openpyxl to plot some data in Excel. However, there can sometimes be more than 256 series which is the maximum limit in Excel.
I am able to create a single plot of up to 256 series, but I am unable to make a new plot if I need to make more plots.
So far, what I have done:
-determined the where the data starts and stops
-calculate how many charts I need
-create a dictionary of different charts
nSeries = last_row - start_Row if (nSeries % 256) == 0: nPolts = nSeries/256 else: nPlots = int(nSeries/256) + 1 d = {} ##dictionary to create variables in a loop for i in range(0,nPlots): d['chart' + str(i)] = ScatterChart()-next I want to loop through the data
-once I reach 256 series, I want to insert that chart and start updating the next chart
###GET PLOTTING nSeries = 0 rowIndex = 2 columnIndex = 2 xvalues = Reference(sheet1, min_col=start_Column, max_col=end_Column, min_row=vds_Row, max_row=vds_Row) chart_Index = 0 for n in d: chart = n for i in range(start_Row, last_row): values = Reference(sheet1, min_col=start_Column, max_col=end_Column, min_row=i, max_row=i) series = Series(values, xvalues, title = sheet.cell(i,1).value) if nSeries <= 256: chart.series.append(series) if nSeries == 256 or i == last_row-1: cellReference = get_column_letter(columnIndex) + str(rowIndex) sheet2.add_chart(chart, cellReference) columnIndex = columnIndex + 10 nSeries = 0 break nSeries = nSeries + 1When I run the last black of code, I get the following error: AttributeError: 'str' object has no attribute 'series' regarding the line
chart.series.append(series)So my question is, how can I create new charts using for loops? Is it possible to do this with a dictionary?