use BoxSpoutWriterWriterFactory;
use BoxSpoutCommonType;
$result = [];
for ($i = 0; $i < 100; $i++) {
$arr = [
'name' => Mock::name(),
'age' =>Mock::number('10-80'),
'email' =>Mock::email(),
'address' =>Mock::address(),
'times'=>Mock::datetime()
];
$result[] = $arr;
}
$reader = WriterFactory::create(Type::XLSX);
$reader->openToBrowser("测试.xlsx");
use BoxSpoutReaderReaderFactory;
use BoxSpoutCommonType;
$path = storage_path('file/a.xlsx');
$type = pathinfo($path);
$type = strtolower($type["extension"]);
$type = ($type === 'xlsx')?Type::XLSX:Type::CSV;
$reader = ReaderFactory::create($type);
$reader->setShouldFormatDates(true);
if($type === 'csv'){$reader->setEncoding('GB2312');}
$reader->open($path);
$iterator = $reader->getSheetIterator();
$iterator->rewind();
$sheet1 = $iterator->current();
$rowIter = $sheet1->getRowIterator();
$data =[];
foreach ($rowIter as $rowIndex => $row) {
$data[] = $row;
}
$reader->close();