E
E
eternalfire2017-11-09 17:38:19
phpspreadsheet
eternalfire, 2017-11-09 17:38:19

How to label cells with numbers only in PHPExcel?

only works like this

$xls->setActiveSheetIndex(0)->setCellValue('A1', $key);

How can I change a column to a number instead of a letter? so far I decided only with a pattern like
$pattern = [
            'А' => '1',
            'B' => '2',
            'C' => '3',
            'D' => '4',
            'E' => '5',
            'F' => '6',
            'G' => '7',
            'H' => '8',
            'I' => '9']

and then the function of searching for the key by value in the array, and then substituting the variable in setCellValue:
$num = 2; // например
$needle = array_search($num, $pattern);
// $needle будет соответственно 'B'

Is there a more general way? Because to infinity, the columns cannot be marked like this

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad, 2017-11-09
@eternalfire

Good evening.
There is a function setCellValueByColumnAndRow()
It accepts integer column and row values.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question