# tablepress/3.4/libraries/vendor/PhpSpreadsheet/NamedFormula.php

TablePress – Tables in WordPress made easy, version 3.4. 46 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/NamedFormula.php
- Raw: https://pluginprobe.com/plugins/tablepress/3.4/raw/libraries/vendor/PhpSpreadsheet/NamedFormula.php
- Modified: 2025-01-08T09:25:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/NamedFormula.php#L10-L20`.

```php
<?php

namespace TablePress\PhpOffice\PhpSpreadsheet;

use TablePress\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class NamedFormula extends DefinedName
{
	/**
	 * Create a new Named Formula.
	 */
	public function __construct(
		string $name,
		?Worksheet $worksheet = null,
		?string $formula = null,
		bool $localOnly = false,
		?Worksheet $scope = null
	) {
		// Validate data
		if (!isset($formula)) {
			throw new Exception('You must specify a Formula value for a Named Formula');
		}
		parent::__construct($name, $worksheet, $formula, $localOnly, $scope);
	}

	/**
	 * Get the formula value.
	 */
	public function getFormula(): string
	{
		return $this->value;
	}

	/**
	 * Set the formula value.
	 */
	public function setFormula(string $formula): self
	{
		if (!empty($formula)) {
			$this->value = $formula;
		}

		return $this;
	}
}

```
