6

How can I get cell column index as integer? I have searched the documentation but I didn't found anything.

user08
  • 695
  • 3
  • 8
  • 25

2 Answers2

18

please see Accessing cells

$ColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($Column);
Abdul Rehman
  • 1,662
  • 3
  • 22
  • 36
saeed yadgari
  • 318
  • 2
  • 8
2

If you have a cell then you can use the public functions - getColumn(), getRow(), getCoordinate()

Go read the source in Github

jhoskins98
  • 114
  • 5
  • This is a first step, which I think OP had found. But getColumn and getCoordinate return strings. OP asked for integer values :) – Pierre-Olivier Vares May 02 '21 at 19:41
  • Once you got the column string coordinate, use `Coordinate::columnIndexFromString($column)` to get the column index [1-n] – Nore Apr 02 '23 at 17:00