PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Calculation\Exception

#NUM!

#NUM!

Error message

#NUM!

What it means

Error "#NUM!" thrown in PHPOffice/PhpSpreadsheet.

Source

Thrown at src/PhpSpreadsheet/Calculation/Financial/Depreciation.php:210

            $period = self::validatePeriod($period);
        } catch (Exception $e) {
            return $e->getMessage();
        }

        if ($period > $life) {
            return ExcelError::NAN();
        }

        $syd = (($cost - $salvage) * ($life - $period + 1) * 2) / ($life * ($life + 1));

        return $syd;
    }

    private static function validateCost(mixed $cost, bool $negativeValueAllowed = false): float
    {
        $cost = FinancialValidations::validateFloat($cost);
        if ($cost < 0.0 && $negativeValueAllowed === false) {
            throw new Exception(ExcelError::NAN());
        }

        return $cost;
    }

    private static function validateSalvage(mixed $salvage, bool $negativeValueAllowed = false): float
    {
        $salvage = FinancialValidations::validateFloat($salvage);
        if ($salvage < 0.0 && $negativeValueAllowed === false) {
            throw new Exception(ExcelError::NAN());
        }

        return $salvage;
    }

    private static function validateLife(mixed $life, bool $negativeValueAllowed = false): float
    {
        $life = FinancialValidations::validateFloat($life);

View on GitHub (pinned to 65b080eef4)

When it happens

Trigger: Thrown at src/PhpSpreadsheet/Calculation/Financial/Depreciation.php:210 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of PHPOffice/PhpSpreadsheet@65b080eef4 (2026-08-17). Data as JSON: /api/errors/9bb23606dfd2746b. Report an issue: GitHub.