Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以使用 fromArray 函数从 A1 到 Ax(垂直)写入 excelsheet?
$objPHPExcel->getActiveSheet()->fromArray($array, NULL, 'A1');
上面这一行的作用是从 A1 写入 X1(水平)。
但是无论如何,输出将是这样的:
$array[0]->A1 $array[1]->A2 $array[2]->A3 $array[x]->A(x+1)
fromArray()适用于二维数组,行然后列。如果您将一维数组作为参数传递,那么它将转换为二维数组,但作为单行的一系列列。
fromArray()
你真的需要传递一个二维数组,所以它是一系列行。
$objPHPExcel->getActiveSheet() ->fromArray(array_map(function($value) { return [$value]; }, $array), NULL, 'A1');