Esta página ainda não foi traduzida para o português, por isso aparece em inglês.

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.

Atualizado em

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.

Seus dados nunca saem do seu computador. Todo o processamento acontece localmente no navegador.

Como usar: 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().

Também pesquisado como: 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.

Ferramentas que combinam com: 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.

Perguntas frequentes

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.
Posso instalar o Excel Formula to Python como um aplicativo da web e usá-lo offline?
Sim. O Excel Formula to Python é um aplicativo da web instalável (PWA) — instalado a partir do seu navegador, não baixado de uma loja de aplicativos. Clique em “Instalar aplicativo” na parte superior desta página no Chrome ou no Edge (Windows, macOS, Linux, ChromeOS) ou, no Android, use “Compartilhar” → “Adicionar à tela inicial” no iPhone e no iPad, ou “Arquivo” → “Adicionar ao Dock” no Safari 17+ em um Mac. Em seguida, ela se abre em uma janela própria com seu próprio ícone e, como é executada inteiramente no seu navegador, continua funcionando offline. O Firefox no desktop não permite a instalação de aplicativos da web. Como funciona a instalação.

Ferramentas relacionadas