|
@@ -11,6 +11,8 @@ use App\Http\Requests\Aside\Domain\DomainInfoRequest; |
|
@@ -11,6 +11,8 @@ use App\Http\Requests\Aside\Domain\DomainInfoRequest; |
|
11
|
use App\Models\Aside\Domain\DomainInfo;
|
11
|
use App\Models\Aside\Domain\DomainInfo;
|
|
12
|
use App\Models\Aside\Domain\DomainInfoLog;
|
12
|
use App\Models\Aside\Domain\DomainInfoLog;
|
|
13
|
use Illuminate\Http\JsonResponse;
|
13
|
use Illuminate\Http\JsonResponse;
|
|
|
|
14
|
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
15
|
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
14
|
use Psr\Container\ContainerExceptionInterface;
|
16
|
use Psr\Container\ContainerExceptionInterface;
|
|
15
|
use Psr\Container\NotFoundExceptionInterface;
|
17
|
use Psr\Container\NotFoundExceptionInterface;
|
|
16
|
|
18
|
|
|
@@ -138,6 +140,43 @@ class DomainInfoController extends BaseController |
|
@@ -138,6 +140,43 @@ class DomainInfoController extends BaseController |
|
138
|
}
|
140
|
}
|
|
139
|
|
141
|
|
|
140
|
|
142
|
|
|
141
|
-
|
143
|
+ /**
|
|
|
|
144
|
+ * @remark :导出数据
|
|
|
|
145
|
+ * @name :exportData
|
|
|
|
146
|
+ * @author :lyh
|
|
|
|
147
|
+ * @method :post
|
|
|
|
148
|
+ * @time :2023/8/1 16:45
|
|
|
|
149
|
+ */
|
|
|
|
150
|
+ public function exportData(){
|
|
|
|
151
|
+ $domainModel = new DomainInfo();
|
|
|
|
152
|
+ $lists = $domainModel->list($this->map);
|
|
|
|
153
|
+ // 创建一个新的 Excel 电子表格实例
|
|
|
|
154
|
+ $spreadsheet = new Spreadsheet();
|
|
|
|
155
|
+ $sheet = $spreadsheet->getActiveSheet();
|
|
|
|
156
|
+ // 添加表头
|
|
|
|
157
|
+ $sheet->setCellValue('A1', 'ID');
|
|
|
|
158
|
+ $sheet->setCellValue('B1', 'Name');
|
|
|
|
159
|
+ $sheet->setCellValue('C1', 'domain');
|
|
|
|
160
|
+ $sheet->setCellValue('D1', 'belong_to');
|
|
|
|
161
|
+ $sheet->setCellValue('E1', 'status');
|
|
|
|
162
|
+ $rowCount = 2;
|
|
|
|
163
|
+ foreach ($lists as $v) {
|
|
|
|
164
|
+ $sheet->setCellValue('A' . $rowCount, $v['id']);
|
|
|
|
165
|
+ $sheet->setCellValue('B' . $rowCount, $v['domain']);
|
|
|
|
166
|
+ $sheet->setCellValue('C' . $rowCount, $v['domain']);
|
|
|
|
167
|
+ $sheet->setCellValue('D' . $rowCount, $v['belong_to']);
|
|
|
|
168
|
+ $sheet->setCellValue('E' . $rowCount, $v['status']);
|
|
|
|
169
|
+ $rowCount++;
|
|
|
|
170
|
+ }
|
|
|
|
171
|
+ // 创建一个新的 Excel Writer 对象
|
|
|
|
172
|
+ $writer = new Xlsx($spreadsheet);
|
|
|
|
173
|
+ // 设置导出文件的保存路径和文件名
|
|
|
|
174
|
+ $this->config = config('filesystems.disks.upload');
|
|
|
|
175
|
+ $filePath = $this->config['root'].'/excel/'.time().'.xlsx';
|
|
|
|
176
|
+ // 导出 Excel 文件
|
|
|
|
177
|
+ $writer->save($filePath);
|
|
|
|
178
|
+ // 返回导出文件的响应
|
|
|
|
179
|
+ return response()->download($filePath)->deleteFileAfterSend(true);
|
|
|
|
180
|
+ }
|
|
142
|
|
181
|
|
|
143
|
} |
182
|
} |