???? ???? ?? ?? ????? ??? ???? ? ????? ?? ??? ?? ? ???? ????. ?? ?? ?? ??? ?????? Excel? ??? ?? ? ???? ?? ?????. ??? ThinkPHP6? ???? Excel? ???? ???? ??? ?? ??? ??? ?????. ? ????? ThinkPHP6? ???? Excel ???? ? ???? ??? ?????.
1. Excel ????
ThinkPHP6? ?? ??? Excel ???? ?? ???? PHPExcel? ?????. PHPExcel? ???? ???? Excel ??? ??? ? ????.
1. json ??? PHPExcel ??? ?????? ?????:
"require": { "phpoffice/phpexcel": "^1.8" },
PHPExcel ??? ?????? ???? ??? ?????:
composer install
2. Excel ???? ???? ???
Excel ???? ??? ???? ???? ??? ???:
namespace appdmincontroller; use PhpOfficePhpSpreadsheetSpreadsheet; use PhpOfficePhpSpreadsheetWriterXlsx as Writer; class Excel extends Base { public function export() { // TODO: 導出Excel } }
3. ??? ?? ??
??? ???? ?, ??? ??? ??? ???? ???. ????? ??? ??? ???? ???? ? ??? ????.
(1) ???????? ??? ????
namespace appdmincontroller; use appdminmodelUser as UserModel; use PhpOfficePhpSpreadsheetSpreadsheet; use PhpOfficePhpSpreadsheetWriterXlsx as Writer; class Excel extends Base { public function export() { $users = UserModel::select()->toArray(); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('A1', 'ID'); $sheet->setCellValue('B1', '姓名'); $sheet->setCellValue('C1', '性別'); $sheet->setCellValue('D1', '年齡'); $row = 2; foreach ($users as $user) { $sheet->setCellValue('A' . $row, $user['id']); $sheet->setCellValue('B' . $row, $user['name']); $sheet->setCellValue('C' . $row, $user['gender']); $sheet->setCellValue('D' . $row, $user['age']); $row++; } $writer = new Writer($spreadsheet); $writer->save('users.xlsx'); } }
(2) ?? ??? ???? ??? ????
?? ???? Excel ??? ???? ??? ?? ???? ???? ?? ?? ?? ?? ???????? ?? ?? ??? Excel ?? ???? ????? ???. ?? ? ???? ???? API ??????? ?? ? ?? ??? ?? ?? ? ????.
namespace appdmincontroller; use GuzzleHttpClient; use PhpOfficePhpSpreadsheetSpreadsheet; use PhpOfficePhpSpreadsheetWriterXlsx as Writer; class Excel extends Base { public function export() { $client = new Client(); $response = $client->get('https://api.example.com/orders'); $orders = json_decode($response->getBody()->getContents(), true); $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('A1', '訂單編號'); $sheet->setCellValue('B1', '下單人'); $sheet->setCellValue('C1', '訂單金額'); $row = 2; foreach ($orders as $order) { $sheet->setCellValue('A' . $row, $order['id']); $sheet->setCellValue('B' . $row, $order['user']); $sheet->setCellValue('C' . $row, $order['amount']); $row++; } $writer = new Writer($spreadsheet); $writer->save('orders.xlsx'); } }
2. Excel ????
ThinkPHP6? ???? Excel ????? ???? ?? ?? ?????. ?? PHPExcel ??? ?????? ???? ?????.
1 PHPExcel ??? ?????? ?????. Excel ???? ??? ???? PHPExcel First Class ?????? ???? ???.
2. Excel ???? ???? ???
Excel ???? ??? ???? ???? ??? ???:
namespace appdmincontroller; use PhpOfficePhpSpreadsheetIOFactory; class Excel extends Base { public function import() { $file = request()->file('file'); $info = $file->validate(['ext' => 'xlsx'])->move('uploads'); if ($info) { $filename = 'uploads/' . $info->getSaveName(); $reader = IOFactory::createReader('Xlsx'); $spreadsheet = $reader->load($filename); $sheet = $spreadsheet->getActiveSheet(); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $data = []; for ($row = 2; $row <= $highestRow; $row++) { $rowData = []; for ($column = 'A'; $column <= $highestColumn; $column++) { $cellValue = $sheet->getCell($column . $row)->getValue(); $rowData[] = $cellValue; } $data[] = $rowData; } unlink($filename); dump($data); } else { echo $file->getError(); } } }
3. Excel ?? ???
???? ??? Excel? ???? ? ??? ??? ??? ??? ???? ???. ??.
<form method="post" action="admin/excel/import" ??????enctype="multipart/form-data"> ??????<input type="file" name="file"> ??????<input type="submit" value="上傳"> </form>
4. ??? ??? ??
Excel? ??? ? PHPExcel?? ???? API? ?? ??? ???? ?? ? ????. ? ????? ?? ??? ???? ???? ????.
$highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $data = []; for ($row = 2; $row <= $highestRow; $row++) { $rowData = []; for ($column = 'A'; $column <= $highestColumn; $column++) { $cellValue = $sheet->getCell($column . $row)->getValue(); $rowData[] = $cellValue; } $data[] = $rowData; }
??? ???? $data ??? ?????. ??????? ???? ???? ?? ?? ??? ?? ??? ??? ? ????.
????? ThinkPHP6? ???? Excel? ???? ???? ?? ??? ?????. PHPExcel ??? ?????? ???? Excel ??? ?? ?? ??? ? ????.
? ??? ThinkPHP6? ???? Excel? ???? ???? ??? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

?? ???? ???? ??? ?? ?? ?? ?? ??? ???? Douyin? ?? ???? ?? ?????. Douyin?? ???? ??? ??? ??? ? ?? ?? ??? ?? ???? ?? ??? ?? ????. ??? ?? ???? ????? ?? ???? ??? ??? ???? ??? ??? ?????. 1. WeChat?? Douyin ??? ??? ????? ?? ??? ?????? ??, Douyin ????? ??? ??? ????? ???? Douyin ??? ???? ?? ??? ????? ???? ???? ???. ???? ???? ?? ??? ? ????. Douyin?? ???? ???? ?? ? ?? ??? ?????? ?? ???? ???? ?? ?? ?? "????? ??" ??? ??? ? ????. ??? ???? ? ???? ???? Douyin? ???? ?????? ??? ? ????. 3. ???? Douyin ???? ?????? ???? ???? ???.

ThinkPHP ????? ????? ??? ?????: Composer? ????, ???? ????? ???? php bin/console? ????, ?? ???? ??? http://localhost:8000? ?????.

ThinkPHP?? ??? PHP ????? ??? ?? ??? ????. ??? ???? 3.2, 5.0, 5.1, 6.0? ????, ??? ??? ??? ???? ??? ??? ???? ? ?????. ?? ?? ??? ThinkPHP 6.0.16???. ??? ??? ? PHP ??, ?? ?? ?? ? ???? ??? ??????. ??? ??? ??? ???? ?? ?? ??? ???? ?? ????.

ThinkPHP Framework? ???? ???? ??: ThinkPHP Framework? ?? ????? ?????? ??? ???. ThinkPHP ?? ????? ???? ?? ???(?? ??)? ????. ?????? ?? ????? ?????. ? ??? ?????. ThinkPHP ??????? ??????. ThinkPHP ?????? URL? ???? ?????.

xmind? ?? ???? ??? ?? ????????. ???? ??? ??? ???? ?? ?? ?????. xmind ??? ?? ??? ????? ?? ??? ?? ???? ??? ? ??? PDF ?? ???? ?????. PDF ???? ??? ??? ? ?? ???? ?????. 1. ?? ????? PDF ??? ???? ??? ????????. [??]-[????] ????? ?????. 2. ?? ??? ??????? [PDF ??]? ???? [??] ??? ?????. 3. ???? ??????? ?? ??, ??, ??? ? ?? ?? ?? ??? ?????. ??? ??? ? [??] ??? ?????. 4. [??] ??? ????

??? ?? ?? ?? ?? ????. ?? ?? ???? ??? ?? ??? ? ???? ????. ??? ?? ? ?? ?? ?????? ??????? ??? QQ Music? ??????? ?? ?? QQ Music? ???? ??? ?? ??? ????? ??? Mac ?????? ??? ? ????. ????? ??? ?? ? ??? QQ Music?? ???? ??? ???? ????? ?? ????. ??? Mac? QQ Music?? ????? ??? ??? ??? ????. ??? ?? MP3 ??? ?????. ??? Mac? QQ Music?? ????? ??? MP3 ???? ???? ??? ?????? Mac? QQ Music?? ????? ??? MP3 ???? ???? ???? ??? ?????? Mac? QQ Music?? ????? ??? MP? ???? ????? ??

Laravel? ThinkPHP ?????? ?? ??: ThinkPHP? ????? ??? ? ??? ??? ?? Laravel?? ??? ????. Laravel? ? ????? ??? ??????? ?? ThinkPHP? ? ??? ? ????.

ThinkPHP ?? ??: PHP, Composer ? MySQL ??? ?????. Composer? ???? ????? ????. ThinkPHP ?????? ???? ?????. ?????? ??? ?????. ?????? ??? ?????. ??????? ???? http://localhost:8000? ?????.
