40 public static function cell(
$row, $column, $relativity = 1, $referenceStyle =
true, $sheetName =
'')
48 if ((
$row < 1) || ($column < 1)) {
52 $sheetName = self::sheetName($sheetName);
54 if ((!is_bool($referenceStyle)) || $referenceStyle === self::REFERENCE_STYLE_A1) {
55 return self::formatAsA1(
$row, $column, $relativity, $sheetName);
58 return self::formatAsR1C1(
$row, $column, $relativity, $sheetName);
61 private static function sheetName(
string $sheetName)
63 if ($sheetName >
'') {
64 if (strpos($sheetName,
' ') !==
false || strpos($sheetName,
'[') !==
false) {
65 $sheetName =
"'{$sheetName}'";
73 private static function formatAsA1(
int $row,
int $column,
int $relativity,
string $sheetName): string
75 $rowRelative = $columnRelative =
'$';
76 if (($relativity == self::ADDRESS_COLUMN_RELATIVE) || ($relativity == self::ADDRESS_RELATIVE)) {
79 if (($relativity == self::ADDRESS_ROW_RELATIVE) || ($relativity == self::ADDRESS_RELATIVE)) {
84 return "{$sheetName}{$columnRelative}{$column}{$rowRelative}{$row}";
87 private static function formatAsR1C1(
int $row,
int $column,
int $relativity,
string $sheetName): string
89 if (($relativity == self::ADDRESS_COLUMN_RELATIVE) || ($relativity == self::ADDRESS_RELATIVE)) {
90 $column =
"[{$column}]";
92 if (($relativity == self::ADDRESS_ROW_RELATIVE) || ($relativity == self::ADDRESS_RELATIVE)) {
96 return "{$sheetName}R{$row}C{$column}";
static formatAsA1(int $row, int $column, int $relativity, string $sheetName)
static cell($row, $column, $relativity=1, $referenceStyle=true, $sheetName='')
ADDRESS.
const ADDRESS_ROW_RELATIVE
const REFERENCE_STYLE_R1C1
const ADDRESS_COLUMN_RELATIVE
static sheetName(string $sheetName)
static formatAsR1C1(int $row, int $column, int $relativity, string $sheetName)
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
static stringFromColumnIndex($columnIndex)
String from column index.