public function setCell($cell, $value, $type = "auto")
    {
        if ($type == "auto") {
            $type = \gettype($value);
        }

        if (\is_array($cell)) {
            $parts["row"] = $cell[0];
            $parts["col"] = $cell[1];
        } else {
            $parts = $this->refToArray($cell);
        }

        if (!\is_array($parts)) {
            \trigger_error("Cell reference should be in the format A1 or array(0,0).", E_USER_ERROR);
            return false;
        }

        $row = $parts["row"];
        $col = $parts["col"];

        switch ($type) {

            case "string" :

                /**
                 * @todo  it would be nice if we were able to keep that
                 * characters UTF-8 or unicode
                 */
                $value = \mb_convert_encoding($value, "Windows-1252", "UTF-8");
                $length = \mb_strlen($value, "Windows-1252");

                if ($length > 255) {
                    \trigger_error("String '$value' is too long. "
                        ."Please keep to a max of 255 characters.",
                        E_USER_ERROR);
                    return false;
                }

                $this->contents .= \pack("s*", 0x0204, 8 + $length, $row, $col, 0x00, $length);
                $this->contents .= $value;

                break;

            case "integer" :
                $this->contents .= \pack("s*", 0x0203, 14, $row, $col, 0x00);
                $this->contents .= \pack("d", $value);
                break;
        }

        return true;
    }
public function setCell($cell, $value, $type = "auto")
    {
        if ($type == "auto") {
            $type = \gettype($value);
        }

        if (\is_array($cell)) {
            $parts["row"] = $cell[0];
            $parts["col"] = $cell[1];
        } else {
            $parts = $this->refToArray($cell);
        }

        if (!\is_array($parts)) {
            \trigger_error("Cell reference should be in the format A1 or array(0,0).", E_USER_ERROR);
            return false;
        }

        $row = $parts["row"];
        $col = $parts["col"];

        switch ($type) {

            case "string" :

                /**
                 * @todo  it would be nice if we were able to keep that
                 * characters UTF-8 or unicode
                 */
                $value = \mb_convert_encoding($value, "Windows-1252", "UTF-8");
                $length = \mb_strlen($value, "Windows-1252");

                if ($length > 255) {
                    \trigger_error("String '$value' is too long. "
                        ."Please keep to a max of 255 characters.",
                        E_USER_ERROR);
                    return false;
                }

                $this->contents .= \pack("s*", 0x0204, 8 + $length, $row, $col, 0x00, $length);
                $this->contents .= $value;

                break;

            case "integer" :
                $this->contents .= \pack("s*", 0x0203, 14, $row, $col, 0x00);
                $this->contents .= \pack("d", $value);
                break;
        }

        return true;
    }
public function setCell ( $ cell , $ value , $ type = "auto" ) { if ( $ type == "auto" ) { $ type = \ gettype ( $ value ) ; } if ( \ is_array ( $ cell ) ) { $ parts [ "row" ] = $ cell [ 0 ] ; $ parts [ "col" ] = $ cell [ 1 ] ; } else { $ parts = $ this -> refToArray ( $ cell ) ; } if ( ! \ is_array ( $ parts ) ) { \ trigger_error ( "Cell reference should be in the format A1 or array(0,0)." , E_USER_ERROR ) ; return false ; } $ row = $ parts [ "row" ] ; $ col = $ parts [ "col" ] ; switch ( $ type ) { case "string" : /**
                 * @todo  it would be nice if we were able to keep that
                 * characters UTF-8 or unicode
                 */ $ value = \ mb_convert_encoding ( $ value , "Windows-1252" , "UTF-8" ) ; $ length = \ mb_strlen ( $ value , "Windows-1252" ) ; if ( $ length > 255 ) { \ trigger_error ( "String '$value' is too long. " . "Please keep to a max of 255 characters." , E_USER_ERROR ) ; return false ; } $ this -> contents .= \ pack ( "s*" , 0x0204 , 8 + $ length , $ row , $ col , 0x00 , $ length ) ; $ this -> contents .= $ value ; break ; case "integer" : $ this -> contents .= \ pack ( "s*" , 0x0203 , 14 , $ row , $ col , 0x00 ) ; $ this -> contents .= \ pack ( "d" , $ value ) ; break ; } return true ; }
Set the value of an individual cell

@param mixed An excel cell reference such as A1, or an array in the
format of ($row, $col) usign zero-based integers
@param mixed the value to put in this cell
@param the type of value (string|integer). Autodetects by default
@return boolean Success
Set the value of an individual cell