[Python] How can I open an Excel file, evaluate formulas, and save the results using Python?

Discussão em 'Python' iniciado por Stack, Agosto 7, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working with Excel files in Python and need to evaluate the formulas in the spreadsheet and then save the resulting values (not the formulas themselves). My goal is to create a workflow where Python opens an .xlsx file, triggers formula evaluation (e.g., =SUM(A1:A5)), and then saves the final values into a new file or replaces the existing formulas with their results.

    Desired behavior:


    • Load an .xlsx file that contains formulas


    • Evaluate all formulas (just like Excel would)


    • Save a new .xlsx file with only the resulting values, or at least with evaluated formulas
    Constraints:

    • Needs to work cross-platform (Windows/Linux ideally) and cloud lambdas
    What I’ve found so far:


    • I read that win32com.client can open Excel and force calculation, but it’s Windows-only and requires Excel to be installed.


    • I've tried pycel and formulas, but they lack some Excel functions that I need, like RANK.
    My question:


    Is there any way to evaluate Excel formulas in Python and save the resulting values back to the file (or a copy)? If not natively, how can I do it with minimal dependencies?

    Continue reading...

Compartilhe esta Página