Excel 解析文件是第一行是中文,出现解析失败的情况
excel文件
订单编号 | 快递公司 | 物流编号 |
---|---|---|
115 | 中通快递 | ZT43443543534 |
116 | 顺丰快递 | SF78798rhhjhjh |
121 | 申通快递 | ST44324hjjkjjdlkfjsd |
代码:
$input = $request->all();
$filePath = $input['order_file'];
$path_url = 'order.xlsx';
$result_url = storage::disk('public')->put($path_url, file_get_contents($filePath));
$path_url_real = 'storage/app/public/'.$path_url;
Excel::load($path_url_real, function($reader) {
$data = $reader->all();
dd($data);
}, 'UTF-8');
运行后截图
RowCollection {#7521 ▼
#heading: array:3 [▼
0 => ""
1 => ""
2 => ""
]
#title: "pay_order"
#items: array:3 [▼
0 => CellCollection {#7527 ▼
#title: null
#items: array:1 [▼
0 => "ZT43443543534"
]
}
1 => CellCollection {#7531 ▼
#title: null
#items: array:1 [▼
0 => "SF78798rhhjhjh"
]
}
2 => CellCollection {#7535 ▼
#title: null
#items: array:1 [▼
0 => "ST44324hjjkjjdlkfjsd"
]
}
]
}
推荐文章: