OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Customized series title in openpyxl python

  • Thread starter Thread starter Hiten Chedda
  • Start date Start date
H

Hiten Chedda

Guest
I am trying to modify the existing xlsx sheet and adding graphs to it using openpyxl module in python.

But while creating a line chart, the series title is shown as Series 1,Series 2,Series 3,Series 4 where as I need to rename the series title as "A", "B", "C", D". (Note: this name are not fetched from any cell)

Another possible solution would to give series name from another worksheet apart from row/column of the same worksheet. But not sure whether it is doable.

Below code give me the series name from row/column of worksheet 'ws'. But I need to rename it (customize name) or assign the series name from another sheet.

Can any one help me on this.?

Code:
c1 = LineChart()
c1.title = worksheet
c1.x_axis.title = "Average depth"
c1.y_axis.title = "Average Response time (ms)"
c1.y_axis.majorGridlines = None

refseries1 = Reference(ws, min_col=5, min_row=2, max_col=5, max_row=9)
seriesdata1 = Reference(ws, min_col=6, min_row=10, max_col=6, max_row=15)

c1.add_data(data=seriesdata1,titles_from_data=False)
c1.set_categories(refseries1)

In above code, refseries1 is xaxis data and seriesdata1 is y axis data.
<p>I am trying to modify the existing xlsx sheet and adding graphs to it using openpyxl module in python.</p>

<p>But while creating a line chart, the series title is shown as Series 1,Series 2,Series 3,Series 4 where as I need to rename the series title as "A", "B", "C", D". (Note: this name are not fetched from any cell)</p>

<p>Another possible solution would to give series name from another worksheet apart from row/column of the same worksheet. But not sure whether it is doable.</p>

<p>Below code give me the series name from row/column of worksheet 'ws'.
But I need to rename it (customize name) or assign the series name from another sheet. </p>

<p>Can any one help me on this.?</p>

<pre><code>c1 = LineChart()
c1.title = worksheet
c1.x_axis.title = "Average depth"
c1.y_axis.title = "Average Response time (ms)"
c1.y_axis.majorGridlines = None

refseries1 = Reference(ws, min_col=5, min_row=2, max_col=5, max_row=9)
seriesdata1 = Reference(ws, min_col=6, min_row=10, max_col=6, max_row=15)

c1.add_data(data=seriesdata1,titles_from_data=False)
c1.set_categories(refseries1)
</code></pre>

<p>In above code, refseries1 is xaxis data and seriesdata1 is y axis data.</p>
 

Latest posts

S
Replies
0
Views
1
Safwan Aipuram
S
Top