I understand that I’ll need to write a loop inside which I use
SetCellValue('cell_name', 'value'); but is there a method in PHPExcel that just accepts a single array and writes that into an Excel sheet row?
$testArray = array('testcelltext1', 'testcelltext2', testcelltext3'); PHPExcel::writeArraytoRow($testArray); //do the other PHPExcel stuff to actually write the file . . . // outputs an excel file in which the PHP array was written to the first row
I could not find something like that in the included documentation, but that might just be bad PDF search skills…
$objPHPExcel->getActiveSheet()->fromArray($testArray, NULL, 'A1');
It’s used in a number of the examples
Arguments as described in the API docs
/** * Fill worksheet from values in array * * @param array $source Source array * @param mixed $nullValue Value in source array that stands for blank cell * @param string $startCell Insert array starting from this cell address as the top left coordinate * @param boolean $strictNullComparison Apply strict comparison when testing for null values in the array * @throws Exception * @return PHPExcel_Worksheet */