Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

Full Support for Array Functions #9

Open
MarkBaker opened this issue Jul 16, 2012 · 1 comment
Open

Full Support for Array Functions #9

MarkBaker opened this issue Jul 16, 2012 · 1 comment
Assignees

Comments

@MarkBaker
Copy link
Member

At the moment, PHPExcel doesn't support array functions.

The first step to rectifying this is a change to the PHPExcel_Cell object to maintain additional information for array formula. The cell containing the actual array formula needs to maintain a range of cells to which that formula is applied; other affected cells need to maintain a link to the array formula "master" so they can access the formula and work out their offset to that cell.

This will affect the values stored in the following attributes:

/**
 *  Value of the cell
 *  The actual cell value for cells that contain a simple value, or the result of the cell
 *      formula calculation if this cell contains a formula, or is part of an array formula.
 *
 *  @var mixed
 */
private $_value;

It will add the following new attributes:

/**
 *  Formula of the cell
 *  NULL for cells that contain a simple value, or where the result is the result of an
 *      indirect array formula ($_arrayFormulaReference will be NOT NULL in this circumstance);
 *      or the formula itself, if this cell contains an actual formula
 *
 *  @var mixed
 */
private $_formula;

/**
 *  Array Formula reference
 *  If this cell contains an array formula then this will contain the range of cells to which
 *      that formula is applied; if the cell is the indirect result of an array formula in a
 *      different cell, then this value will be a simple reference to the cell that holds the
 *      actual formula; if the cell is a simple value cell, then this will be a NULL value.
 *
 *  @var mixed
 */
private $_arrayFormulaRef;

The following attribute will be dropped from the cell:

/**
 *  Attributes of the formula
 *
 */
private $_formulaAttributes;

as its purpose is superceded by the other changes to the cell structure, but which allow rather for flexibility when working with array functions.

As examples for the changes of attributes related to formulae and array formulae:

Cell A1 contains 1, cell A2 contains 2, cell A3 contains 3, cell A4 contains 4

            $_value     $_formula       $_arrayFormulaRef
            --------    ----------      ------------------
Cell C1     "Result"    NULL            NULL                Simple Value, in this case a string
Cell C2         30      =2*3*5              NULL            Simple Formula
Cell C3         6       =2*3*A1:A4          C3:C6           Array Formula
Cell C4         12      NULL                    C3          Result dependent on Array Formula
Cell C5         18      NULL                    C3          Result dependent on Array Formula
Cell C6         24      NULL                    C3          Result dependent on Array Formula

To facilitate getting and setting formulae and array formulae, a number of new methods need adding, and other existing methods need modifying.
First and foremost, getFormula() and setFormula() methods will be added as the primary methods for setting and retrieving formulae for cells; isFormula() and isArrayFormula() will identify whether a cell contains a formula or an array formula or not; getArrayFormulaRange() will identify the cell range for an array formula; getValue() will be modified to retrieve calculated values; while getCalculatedValue() will be deprecated; setValue() and setValueExplicit() will still perform the same function as at present, but will be modified to handle storing formulae in the new properties where the data passed is identified as a formula.

These changes to the cell structure and methods will start with version 1.7.9, so deprecated methods will be flagged as deprecated in the 1.7.8 release, but retain their existing functionality until the 1.7.9 release.

@dostmann
Copy link

dostmann commented Feb 7, 2017

Is there any progress in this issue? Would be great...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants