我知道如何将2D数组附加到全新行中的图纸上。
但是在我的情况下,我需要将2D数组数据设置为下面的“ B1:G3”范围。
2D数组数据:
[
["2018-01","2018-02","2018-03",....,"2018-12","Total"],
[100,200,300,....,400,2000],
[10,20,33,....,44,300]
]
如何完成。
顺便说一下,我使用maatwebsite / excel 2.1.0
谢谢您的帮助。
答案 0 :(得分:0)
最后我在Laravel Excel的源代码中找到了这个。
我可以在下面使用:
$sheet->fromArray($2DArrayData, null, 'B1', true, false);
参数含义:
/**
* Fill worksheet from values in array
*
* @param array $source Source array
* @param mixed $nullValue Value in source array that stands for blank cell
* @param bool|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
* @param bool $headingGeneration
* @throws PHPExcel_Exception
* @return LaravelExcelWorksheet
*/
public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false, $headingGeneration = true)
{