adding rowcolToCell() (JT Hughes)
git-svn-id: https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer/trunk@141432 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
e461d9b467
commit
8c60af5d88
29
Writer.php
29
Writer.php
|
|
@ -71,5 +71,34 @@ class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
|
||||||
header("Pragma: public");
|
header("Pragma: public");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function for writing formulas
|
||||||
|
* Converts a cell's coordinates to the A1 format.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
|
* @param integer $row Row for the cell to convert (0-indexed).
|
||||||
|
* @param integer $col Column for the cell to convert (0-indexed).
|
||||||
|
* @return string The cell identifier in A1 format
|
||||||
|
*/
|
||||||
|
function rowcolToCell($row, $col)
|
||||||
|
{
|
||||||
|
if ($col > 255) { //maximum column value exceeded
|
||||||
|
return new PEAR_Error("Maximum column value exceeded: $col");
|
||||||
|
}
|
||||||
|
|
||||||
|
$int = (int)($col / 26);
|
||||||
|
$frac = $col % 26;
|
||||||
|
$chr1 = '';
|
||||||
|
|
||||||
|
if ($int > 0) {
|
||||||
|
$chr1 = chr(ord('A') + $int - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$chr2 = chr(ord('A') + $frac);
|
||||||
|
$row++;
|
||||||
|
|
||||||
|
return $chr1.$chr2.$row;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue