数组php到对象电子表格



我有一个数组php,我想在对象电子表格中转换;我使用有关电子表格PHP的库。我已经尝试了一些方法,但是例如,我写了:

$writer = PhpOfficePhpSpreadsheetIOFactory::createWriter($result, "Xls");

和$结果是一个数组,我有错误,因为$result不是对象。我有一个错误:

unturew typeerror:参数1传递给 phpoffice phpspreadsheet iofactory :: createwriter()必须是一个实例 phpoffice phpspreadsheet 电子表格,给定的数组,调用 c: xampp3 htdocs sincro parts_europe.php在第166行中定义 c: xampp3 htdocs sincro vendor phpoffice phpspreadsheet src src phpspreadsheet iofactory.php:47 堆栈跟踪:#0 c: xampp3 htdocs sincro parts_europe.php(166): phpoffice phpspreadsheet iofactory :: createwriter(array,'xls')#1 {main}扔进 C: Xampp3 htdocs sincro vendor phpoffice phpspreadsheet src src phpspreadsheet iofactory.php 在第47行

谢谢

$result必须是 phpoffice phpspreadsheet everdsheet 的实例,请尝试将其作为对象而不是像下面的代码:

$result = new PhpOfficePhpSpreadsheetSpreadsheet();
$writer = PhpOfficePhpSpreadsheetIOFactory::createWriter($result, "Xls");

相关内容

最新更新