Worksheet::writeFormula
Вернуться к: Spreadsheet_Excel_Writer
Worksheet::writeFormula
Synopsis
integer Worksheet::writeFormula ( integer $row , integer $col , string $formula , mixed $format=0 )
Write a formula to the specified row and column (zero indexed). In case of error it will write the error message (instead of the formula) in the corresponding row and column.
Parameter
-
integer $row - Zero indexed row
-
integer $col - Zero indexed column
-
string $formula - The formula text string
-
mixed $format - The optional XF format
Return value
integer - 0 for normal termination, -1 for an error in the formula, -2 for row or column out of range.
Note
This function can not be called statically.
Formulas must start with an equal sign ('=').
Arguments given to an Excel function should be separated by comas (','), not by semicolons (';').
Example
Using writeFormula()
<?php
require_once 'Spreadsheet/Excel/Writer.php';
$workbook = new Spreadsheet_Excel_Writer('formula.xls');
$worksheet =& $workbook->addWorksheet();
$worksheet->write(0, 0, 2);
$worksheet->write(0, 1, "and");
$worksheet->write(0, 2, 2);
$worksheet->write(0, 3, "makes");
$worksheet->writeFormula(0, 4, "=SUM(A1,C1)");
$workbook->close();
?>
Вернуться к: Spreadsheet_Excel_Writer