I
I
igortyulkin2018-05-17 16:19:33
PHP
igortyulkin, 2018-05-17 16:19:33

How to get PHPExcel column array?

Good afternoon, tell me if there is a method in PHPExcel to get all the values ​​in a column into an array and similar with the construction?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iljaGolubev, 2018-05-17
@iljaGolubev

rangeToArray
as "with construction" - I don't know

I
igortyulkin, 2018-05-18
@igortyulkin

issue resolved

$sheet = $objPHPExcel->getActiveSheet();
$array_data = array();
foreach($sheet->getRowIterator() as $row){
    $rowIndex = $row->getRowIndex ();
    $array_data[$rowIndex] = array('A'=>'', 'B'=>'','C'=>'','D'=>'');
     
    $cell = $sheet->getCell('A' . $rowIndex);
    $array_data[$rowIndex]['A'] = $cell->getCalculatedValue();
    $cell = $sheet->getCell('B' . $rowIndex);
    $array_data[$rowIndex]['B'] = $cell->getCalculatedValue();
    $cell = $sheet->getCell('C' . $rowIndex);
    $array_data[$rowIndex]['C'] = $cell->getCalculatedValue();
    $cell = $sheet->getCell('D' . $rowIndex);
    $array_data[$rowIndex]['D'] = $cell->getCalculatedValue();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question