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?
Something like:
$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...
PHP Excel was officially deprecated in 2017 and permanently archived in 2019. PHP Excel has not be maintained for years and must not be used anymore. All users must migrate to its direct successor PhpSpreadsheet, or another alternative.
function toNumber($dest) { if ($dest) return ord(strtolower($dest)) - 96; else return 0; } function myFunction($s,$x,$y){ $x = toNumber($x); return $s->getCellByColumnAndRow($x, $y)->getFormattedValue(); } $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); $ ...
To retrieve the value of a cell, the cell should first be retrieved from the worksheet using the getCell() method. A cell's value can be read using the getValue() method. // Get the value from cell A1 $cellValue = $spreadsheet->getActiveSheet()->getCell('A1')->getValue();
$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 */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With