Commit e450280d by 赵增煜

增加sheetname打印

parent 8c560c8d
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Dcat\Admin\Http\JsonResponse; use Dcat\Admin\Http\JsonResponse;
use Dcat\Admin\Widgets\Form; use Dcat\Admin\Widgets\Form;
use Dcat\EasyExcel\Excel; use Dcat\EasyExcel\Excel;
use Dcat\EasyExcel\Sheet;
use Dcat\EasyExcel\Support\SheetCollection; use Dcat\EasyExcel\Support\SheetCollection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Exception; use Exception;
...@@ -31,6 +32,10 @@ public function handle(array $input): JsonResponse ...@@ -31,6 +32,10 @@ public function handle(array $input): JsonResponse
$filePath = storage_path('app/'.$file); $filePath = storage_path('app/'.$file);
// Log::info("====>".$filePath); // Log::info("====>".$filePath);
try { try {
$excel = Excel::import($filePath)->toArray();
// Get the sheet names from the file
$sheetNames = $excel[0]->getSheetNames();
Log::info("====>".$sheetNames."====>".json_encode($excel));
// 每100行数据为一批数据进行读取 // 每100行数据为一批数据进行读取
$chunkSize = 10; $chunkSize = 10;
$successNum = 0; $successNum = 0;
...@@ -113,7 +118,7 @@ public function form() ...@@ -113,7 +118,7 @@ public function form()
->required() ->required()
->help("导入要求:<br /> ->help("导入要求:<br />
<span style='color:red;'> <span style='color:red;'>
1、支持xlsx、csv两种格式 1、仅支持xlsx两种格式
</span>"); </span>");
// $downloadUrl = admin_url('dosage-template'); // $downloadUrl = admin_url('dosage-template');
// $this->html("<a target='_blank' href='{$downloadUrl}'>下载用法用量导入模板</a>"); // $this->html("<a target='_blank' href='{$downloadUrl}'>下载用法用量导入模板</a>");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment