I am trying to convert a JSON file to CSV using SimpleExcel: https://github.com/faisalman/simple-excel-php
我正在尝试使用SimpleExcel将JSON文件转换为CSV:https://github.com/faisalman/simple-excel-php
Following the documentation, I created the following PHP file:
在文档之后,我创建了以下PHP文件:
<?
use SimpleExcel\SimpleExcel;
echo "test";
$excel = new SimpleExcel('JSON');
$excel->parser->loadFile('test.json');
echo $excel->parser->getCell(1, 1);
$excel->convertTo('CSV');
$excel->writer->addRow(array('add', 'another', 'row'));
$excel->writer->saveFile('example');
?>
Where test.json is local. For some reason this doesn't work. I was hoping it could create a CSV locally but instead it gives an error:
test.json是本地的。出于某种原因,这不起作用。我希望它可以在本地创建一个CSV,但它会给出一个错误:
test Fatal error: Class 'SimpleExcel\SimpleExcel' not found in test.php on line 7
test致命错误:第7行的test.php中找不到类'SimpleExcel \ SimpleExcel'
Any tips would be greatly appreciated. Most of their examples focus on converting CSV to XML.
任何提示将非常感谢。他们的大多数示例都专注于将CSV转换为XML。
Thanks
1 个解决方案
#1
1
If you are not autoloading classes, you still need to include/require_once the SimpleExcel source files.
如果您不是自动加载类,则仍需要包含/ require_once SimpleExcel源文件。
#1
1
If you are not autoloading classes, you still need to include/require_once the SimpleExcel source files.
如果您不是自动加载类,则仍需要包含/ require_once SimpleExcel源文件。