一、laravel框架
(1)Excel数据导出为数组
$path_all1 = '/data/user_data.xlsx';
if (!file_exists($path_all1)) {
return $this->fail('文件不存在');
}
$now = date('Y-m-d H:i:s');
$data1 = [];
Excel::load($path_all1, function ($reader) use (&$data1) {
$reader = $reader->getSheet(0);
$data1 = $reader->toArray();
});
(2)Excel数据导出为txt文件
if (count($result) > 0) {
$result = json_encode($result, JSON_UNESCAPED_UNICODE);
file_put_contents('/mnt/vdc/groupInfo.txt', $result);
}
(3)将数据导出为Excel文件
$excel_name = 'deposits_05_1';
$info = Excel::create($excel_name, function ($excel) use ($orders) {
$excel->sheet('deposits', function ($sheet) use ($orders) {
$sheet->rows($orders);
});
})->store('xlsx');
二、tp5的Excel导入
public function load(){
$controller = $this->request->controller();
if ($this->request->isAjax()){
$file = $this->request->post(false);
$file = $this->req