[Python] Openpyxl: Save Chart As Sheet

Discussão em 'Python' iniciado por Stack, Janeiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    Wondering if there is a way or workaround to save a chart as a sheet using Openpyxl?

    I've been able to create the charts and place them within a sheet at a specific location:

    from openpyxl import Workbook, load_workbook
    from openpyxl.chart import LineChart, Reference

    def create_chart(worksheet):
    chart = LineChart()
    chart.title = "My Line Chart"
    data = Reference(workbook['Data'], min_col=8, min_row=3, max_row=10, max_col=11)
    categories = Reference(workbook['Data'], min_col=7, min_row=3, max_row=10, max_col=7)
    chart.add_data(data)
    chart.set_categories(categories)
    worksheet.add_chart(chart, 'A1')


    Is there a way I could change that last line to send it to a full sheet? Or increase the size?

    Continue reading...

Compartilhe esta Página