Esta página aún no está traducida al español, así que la mostramos en inglés.

Excel Formula to PHP Converter

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.

Actualizado el

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.

Tus datos nunca salen de tu ordenador. Todo se procesa localmente en tu navegador.

Cómo usar: Excel Formula to PHP

  1. Paste an Excel or Google Sheets formula, or pick one from Examples.
  2. Choose the target language — the page starts with PHP, 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.

Turning spreadsheet formulas into PHP

Quotes, invoices, shipping costs and commission rules are often specified in Excel and then implemented in a PHP application — Laravel, Symfony, WordPress or WooCommerce. This converter reads the formula with Excel's operator precedence and writes PHP 8 code you can drop into a service class or helper file.

=IFERROR(VLOOKUP(A2, Products!A2:C500, 3, FALSE), "Not found")

function calculate($a2, $products_a2_c500)
{
    return if_error(fn() => vlookup($a2, $products_a2_c500, 3, false), 'Not found');
}

How Excel functions map to PHP

ExcelPHP
IF(c, a, b)c ? a : b
IFS / SWITCHparenthesized ternaries
AND, OR, NOT&&, ||, !
= and <>== and !=
a & b$a . $b
a ^ b$a ** $b
SUM(A2:A10)array_sum($a2_a10)
ROUND(x, 2)round($x, 2)
MOD(a, b)excel_mod() helper
SUMIFS / COUNTIF…sum_ifs(), count_if() helpers
VLOOKUP / XLOOKUPvlookup(), xlookup() helpers
IFERROR(x, y)if_error(fn() => x, y)
LEFT / MID / LENmb_substr(), mb_strlen()
TODAY() / NOW()new DateTime()

PHP-specific details

  • Nested ternaries. Since PHP 8, unparenthesized nested ternaries are a fatal error. Every nested IF is wrapped in parentheses automatically.
  • Concatenation precedence. In PHP 8, + and - bind tighter than ., so "Total: " . $a + $b adds first. The converter keeps Excel's meaning either way.
  • Multibyte text. LEFT, MID, LEN, UPPER and LOWER use the mb_* functions, so accented characters and emoji count as one character, like in Excel.
  • FIND and SEARCH. strpos() returns false or a 0-based offset; the find_pos() helper returns Excel's 1-based position (0 when not found).
  • MOD. PHP's % and fmod() keep the sign of the dividend; excel_mod() matches Excel for negative numbers.
  • Errors. IFERROR catches DivisionByZeroError and lookup failures through if_error(fn() => …), using arrow functions (PHP 7.4+).
  • Dates. TODAY(), DATE() and YEAR() use DateTime objects.

Using the output

Helpers are plain functions placed above your function. In a framework, move them into a helper file or make them static methods on a class. Ranges are PHP arrays: a single column is a list, and a multi-column range is a list of rows.

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. To bring the sheet's data along, convert it with Excel to PHP array.

También se busca como: excel to php, excel formula to php code, convert excel formula to php, vlookup in php, sumif in php, excel formula laravel, spreadsheet formula to php.

Herramientas que combinan con: Excel Formula to PHP

  • 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 Python — 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.
  • 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.
  • CSV & Excel to SQL — Paste CSV or Excel cells, or open an .xlsx file, and get ready-to-run CREATE TABLE and INSERT statements with correctly escaped values for your database.

Preguntas frecuentes

Which PHP version does the output need?
PHP 8.0 or newer is recommended. Arrow functions (used by IFERROR) need PHP 7.4, and the ** operator needs PHP 5.6.
Why are the string functions mb_substr and mb_strlen?
They count characters instead of bytes, so text with accents or emoji gives the same result as Excel. They need the mbstring extension, which is enabled on almost every PHP install.
How do I pass a range to the function?
As an array. A2:A10 becomes a flat array of values; A2:C500 becomes an array of rows, the format vlookup() expects.
Is my formula sent to a server?
No — conversion happens in your browser.
¿Puedo instalar Excel Formula to PHP como aplicación web y utilizarla sin conexión?
Sí. Excel Formula to PHP es una aplicación web instalable (PWA): se instala desde el navegador, no se descarga desde una tienda de aplicaciones. Haz clic en «Instalar aplicación» en la parte superior de esta página en Chrome o Edge (Windows, macOS, Linux, ChromeOS) o, en Android, utiliza «Compartir» → «Añadir a la pantalla de inicio» en iPhone y iPad, o «Archivo» → «Añadir al Dock» en Safari 17+ en un Mac. A continuación, se abrirá en su propia ventana con su propio icono y, como se ejecuta íntegramente en tu navegador, seguirá funcionando sin conexión. Firefox en el ordenador de sobremesa no permite instalar aplicaciones web. Cómo funciona la instalación.

Herramientas relacionadas