Shiro Shiro - 4 months ago 36
PHP Question

php PHPExcel split Excel cell coordinate

currently, I used PHPExcel to import excel file,
there is a function

$cell->getCoordinate();


I would like to ask any solution for split the cell coordinate
alphabet
and
integer
?

e.g A1, A2,

I need to know currently which row, and until which column.

I do some research about split, but not luck for it. Any idea?

Answer

This:

$coord = 'AF13';
preg_match_all('~[A-Z]+|\d+~', $coord, $split);
print_r($split);

Will produce:

Array (
  [0] => Array (
    [0] => AF
    [1] => 13
  )
)