[Python] Python - Open Excel workbook in smaller proportions

Discussão em 'Python' iniciado por Stack, Abril 28, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using this code (adjusted example I found somewhere) to generate an excel file. It works as expected, with just one problem which is that when opening the file it always opens full screen which is very annoying to the end user. Is there a way to adjust the settings of the file?

    jsreport = filtered_report
    if isinstance(jsreport, dict):
    jsreport = [jsreport]
    df = pd.DataFrame(jsreport)

    # Generate the Excel file in memory
    output = BytesIO()
    with pd.ExcelWriter(output, engine='openpyxl') as writer:
    df.to_excel(writer, index=False)
    output.seek(0)

    # Send the file to the user for download
    return send_file(output, as_attachment=True, download_name=f"report_{month_year}.xlsx", mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')


    Was looking at these pieces of documentation, but I can't find what I'm looking for. https://pandas.pydata.org/docs/reference/api/pandas.ExcelWriter.html https://openpyxl.readthedocs.io/en/3.1/api/openpyxl.worksheet.dimensions.html

    Continue reading...

Compartilhe esta Página