Cette page n’est pas encore traduite en français : elle s’affiche en anglais.

Excel Formula to Python Converter

Paste an Excel or Google Sheets formula and get a Python function with clean variable names, the right imports and helpers for SUMIFS, VLOOKUP and Excel-style rounding.

Mis à jour le

Paste with or without the leading =. Commas and semicolons both work as argument separators.

Output

Cell references

References appear here once you enter a formula.

Give references meaningful names (B2 → price). Ranges become lists; multi-column ranges become lists of rows.

Vos données ne quittent jamais votre ordinateur. Tout le traitement se fait localement dans votre navigateur.

Comment utiliser : Excel Formula to Python

  1. Paste an Excel or Google Sheets formula, or pick one from Examples.
  2. Choose the target language — the page starts with Python, and you can switch at any time.
  3. Rename the detected cell references to meaningful variable names, for example B2 → price.
  4. Choose a full function or the bare expression, then copy or download the code. Helper functions are added automatically when a formula needs them.

Moving spreadsheet logic into Python

Data teams regularly rebuild Excel models in Python — to automate a monthly report, feed a pandas pipeline or move a calculation behind an API. Re-typing formulas is slow and risky, because Python and Excel disagree on details like rounding and text comparison. This converter parses the formula with Excel's own precedence rules and writes equivalent, readable Python.

=SUMIFS(D2:D100, B2:B100, "North", C2:C100, ">=1000")

def calculate(d2_d100, b2_b100, c2_c100):
    return sum_ifs(d2_d100, b2_b100, 'North', c2_c100, '>=1000')

The sum_ifs() helper (and the matches_criteria() function it uses) is included above the function, so the output runs as-is.

How Excel functions map to Python

ExcelPython
IF(c, a, b)a if c else b
IFS / SWITCHchained conditional expressions
AND, OR, NOTand, or, not
= and <>== and !=
a & bstr(a) + str(b)
a ^ ba ** b
SUM(A2:A10)sum(a2_a10)
ROUND(x, 2)excel_round() helper — not round()
MOD(a, b)a % b
SUMIFS / COUNTIF…sum_ifs(), count_if() helpers
VLOOKUP / XLOOKUPvlookup(), xlookup() helpers
IFERROR(x, y)if_error(lambda: x, y)
LEFT / MID / LENslicing, len()
TODAY() / NOW()date.today(), datetime.now()

Pitfalls the converter handles

  • Banker's rounding. Python's round(2.5) returns 2 and round(0.125, 2) returns 0.12; Excel gives 3 and 0.13. The output uses an excel_round() helper based on Decimal with ROUND_HALF_UP.
  • Concatenation. "Total: " + 5 raises a TypeError in Python, so every non-text operand of & is wrapped in str().
  • IF is an expression. IF becomes Python's conditional expression (a if c else b), and nested IFs chain naturally.
  • Integer division. Python 3's / always returns a float, matching Excel.
  • Errors. IFERROR becomes if_error(lambda: …, fallback), which catches ZeroDivisionError, LookupError from lookups and other exceptions.
  • Dates. DATE, TODAY and YEAR map to the datetime module. Excel rolls over invalid dates (month 13); Python raises an error, and the converter warns you.

Working with pandas

Generated functions work on scalars and lists. To apply a row-wise formula to a DataFrame, call it with df.apply(lambda r: calculate(r.price, r.qty), axis=1); for aggregates such as SUMIFS, pandas boolean masks (df.loc[(df.region == 'North') & (df.total >= 1000), 'amount'].sum()) are faster on large data.

Supported functions: IF, IFS, SWITCH, AND, OR, NOT, XOR, IFERROR, IFNA, ISBLANK, ISNUMBER, ISTEXT, SUM, AVERAGE, MIN, MAX, COUNT, COUNTA, COUNTBLANK, PRODUCT, MEDIAN, ROUND, ROUNDUP, ROUNDDOWN, INT, TRUNC, ABS, SIGN, MOD, POWER, SQRT, EXP, LN, LOG, LOG10, PI, CEILING, FLOOR, RAND, RANDBETWEEN, SUMIF, SUMIFS, COUNTIF, COUNTIFS, AVERAGEIF, AVERAGEIFS, SUMPRODUCT, VLOOKUP, XLOOKUP, MATCH, INDEX, CONCAT, CONCATENATE, TEXTJOIN, LEFT, RIGHT, MID, LEN, UPPER, LOWER, PROPER, TRIM, SUBSTITUTE, REPLACE, FIND, SEARCH, REPT, VALUE, EXACT, TEXT (number formats), TODAY, NOW, DATE, YEAR, MONTH, DAY. Load the spreadsheet itself with Excel to JSON and json.load().

Aussi recherché comme : excel to python, excel formula to python code, convert excel formula to python, excel formula pandas, google sheets formula to python, spreadsheet formula to python, vlookup in python.

Outils complémentaires : Excel Formula to Python

  • Excel Formula to JavaScript — Paste a spreadsheet formula and get readable JavaScript: a function with named parameters, correct operator precedence and small helper functions for things JavaScript lacks, such as SUMIFS and VLOOKUP.
  • Excel Formula to SQL — Paste an Excel formula and get the equivalent SQL expression or SELECT query — IF and IFS as CASE WHEN, SUMIFS and COUNTIFS as conditional aggregates, and the right string and date functions for your database.
  • Excel Formula to PHP — Paste a spreadsheet formula and get a PHP 8 function: parenthesized ternaries, mb_* string functions, and helpers for lookups, conditional sums and Excel-style MOD.
  • CSV to JSON — Paste CSV or TSV and get a JSON array of objects.

Questions fréquentes

Why does the output use excel_round() instead of round()?
Python rounds halves to the nearest even number (banker's rounding), so round(2.5) is 2. Excel rounds halves away from zero. The helper reproduces Excel exactly.
Does it work with pandas DataFrames?
The functions take plain values and lists. Pass DataFrame columns with .tolist(), or apply a row-wise function with df.apply(…, axis=1).
How is VLOOKUP translated?
As a vlookup(value, table, column, approximate) helper where the table is a list of rows. Exact match (FALSE) compares text case-insensitively like Excel, and a missing value raises LookupError, which IFERROR catches.
Which Python version is required?
Python 3.8 or newer. Only the standard library is used (math, statistics, decimal, re, fnmatch, datetime), and imports are added only when needed.
Is the formula uploaded anywhere?
No. The conversion runs in your browser.
Puis-je installer Excel Formula to Python en tant qu’application web et l’utiliser hors ligne ?
Oui. Excel Formula to Python est une application web installable (PWA) : elle s’installe depuis votre navigateur, sans passer par une boutique d’applications. Cliquez sur « Installer l’application » en haut de cette page dans Chrome ou Edge (Windows, macOS, Linux, ChromeOS) ; sur Android, utilisez « Partager » → « Ajouter à l’écran d’accueil » sur iPhone et iPad ; ou « Fichier » → « Ajouter au Dock » dans Safari 17+ sur Mac. L’application s’ouvre alors dans sa propre fenêtre avec sa propre icône, et comme elle s’exécute entièrement dans votre navigateur, elle continue de fonctionner hors ligne. Firefox sur ordinateur de bureau ne permet pas d’installer d’applications web. Comment fonctionne l’installation.

Outils similaires