Commit 6b5dca57f06f1585235d433131bf37e7a24050cf

Authored by Андрей Ларионов
1 parent 01e6816d26

Компонент для работы с экселем

Showing 5 changed files with 370 additions and 3 deletions Side-by-side Diff

app/Http/Controllers/PagesController.php
... ... @@ -5,6 +5,8 @@ namespace App\Http\Controllers;
5 5 use App\Models\pages;
6 6 use Illuminate\Http\Request;
7 7 use Illuminate\Support\Facades\Redis;
  8 +use PhpOffice\PhpSpreadsheet\Spreadsheet;
  9 +use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
8 10  
9 11 class PagesController extends Controller
10 12 {
... ... @@ -24,4 +26,13 @@ class PagesController extends Controller
24 26 dd($values);
25 27  
26 28 }
  29 +
  30 + public function excel() {
  31 + $spreadsheet = new Spreadsheet();
  32 + $activeWorksheet = $spreadsheet->getActiveSheet();
  33 + $activeWorksheet->setCellValue('A1', 'Hello World !');
  34 +
  35 + $writer = new Xlsx($spreadsheet);
  36 + $writer->save('hello_world.xlsx');
  37 + }
27 38 }
... ... @@ -14,8 +14,8 @@
14 14 "laravel/framework": "^9.19",
15 15 "laravel/sanctum": "^3.0",
16 16 "laravel/tinker": "^2.7",
17   - "laravel/ui": "^4.2"
18   -
  17 + "laravel/ui": "^4.2",
  18 + "phpoffice/phpspreadsheet": "^1.29"
19 19 },
20 20 "require-dev": {
21 21 "barryvdh/laravel-debugbar": "^3.9",
... ... @@ -4,7 +4,7 @@
4 4 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 5 "This file is @generated automatically"
6 6 ],
7   - "content-hash": "20183a94ace5a057147d8f922629489d",
  7 + "content-hash": "e00756e0febf0cc362b59b2f6f9fa84c",
8 8 "packages": [
9 9 {
10 10 "name": "akaunting/laravel-money",
... ... @@ -747,6 +747,67 @@
747 747 "time": "2023-01-02T17:26:14+00:00"
748 748 },
749 749 {
  750 + "name": "ezyang/htmlpurifier",
  751 + "version": "v4.16.0",
  752 + "source": {
  753 + "type": "git",
  754 + "url": "https://github.com/ezyang/htmlpurifier.git",
  755 + "reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8"
  756 + },
  757 + "dist": {
  758 + "type": "zip",
  759 + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/523407fb06eb9e5f3d59889b3978d5bfe94299c8",
  760 + "reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8",
  761 + "shasum": ""
  762 + },
  763 + "require": {
  764 + "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0"
  765 + },
  766 + "require-dev": {
  767 + "cerdic/css-tidy": "^1.7 || ^2.0",
  768 + "simpletest/simpletest": "dev-master"
  769 + },
  770 + "suggest": {
  771 + "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.",
  772 + "ext-bcmath": "Used for unit conversion and imagecrash protection",
  773 + "ext-iconv": "Converts text to and from non-UTF-8 encodings",
  774 + "ext-tidy": "Used for pretty-printing HTML"
  775 + },
  776 + "type": "library",
  777 + "autoload": {
  778 + "files": [
  779 + "library/HTMLPurifier.composer.php"
  780 + ],
  781 + "psr-0": {
  782 + "HTMLPurifier": "library/"
  783 + },
  784 + "exclude-from-classmap": [
  785 + "/library/HTMLPurifier/Language/"
  786 + ]
  787 + },
  788 + "notification-url": "https://packagist.org/downloads/",
  789 + "license": [
  790 + "LGPL-2.1-or-later"
  791 + ],
  792 + "authors": [
  793 + {
  794 + "name": "Edward Z. Yang",
  795 + "email": "admin@htmlpurifier.org",
  796 + "homepage": "http://ezyang.com"
  797 + }
  798 + ],
  799 + "description": "Standards compliant HTML filter written in PHP",
  800 + "homepage": "http://htmlpurifier.org/",
  801 + "keywords": [
  802 + "html"
  803 + ],
  804 + "support": {
  805 + "issues": "https://github.com/ezyang/htmlpurifier/issues",
  806 + "source": "https://github.com/ezyang/htmlpurifier/tree/v4.16.0"
  807 + },
  808 + "time": "2022-09-18T07:06:19+00:00"
  809 + },
  810 + {
750 811 "name": "filament/forms",
751 812 "version": "v2.17.40",
752 813 "source": {
... ... @@ -2570,6 +2631,194 @@
2570 2631 "time": "2023-03-03T20:12:38+00:00"
2571 2632 },
2572 2633 {
  2634 + "name": "maennchen/zipstream-php",
  2635 + "version": "3.1.0",
  2636 + "source": {
  2637 + "type": "git",
  2638 + "url": "https://github.com/maennchen/ZipStream-PHP.git",
  2639 + "reference": "b8174494eda667f7d13876b4a7bfef0f62a7c0d1"
  2640 + },
  2641 + "dist": {
  2642 + "type": "zip",
  2643 + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/b8174494eda667f7d13876b4a7bfef0f62a7c0d1",
  2644 + "reference": "b8174494eda667f7d13876b4a7bfef0f62a7c0d1",
  2645 + "shasum": ""
  2646 + },
  2647 + "require": {
  2648 + "ext-mbstring": "*",
  2649 + "ext-zlib": "*",
  2650 + "php-64bit": "^8.1"
  2651 + },
  2652 + "require-dev": {
  2653 + "ext-zip": "*",
  2654 + "friendsofphp/php-cs-fixer": "^3.16",
  2655 + "guzzlehttp/guzzle": "^7.5",
  2656 + "mikey179/vfsstream": "^1.6",
  2657 + "php-coveralls/php-coveralls": "^2.5",
  2658 + "phpunit/phpunit": "^10.0",
  2659 + "vimeo/psalm": "^5.0"
  2660 + },
  2661 + "suggest": {
  2662 + "guzzlehttp/psr7": "^2.4",
  2663 + "psr/http-message": "^2.0"
  2664 + },
  2665 + "type": "library",
  2666 + "autoload": {
  2667 + "psr-4": {
  2668 + "ZipStream\\": "src/"
  2669 + }
  2670 + },
  2671 + "notification-url": "https://packagist.org/downloads/",
  2672 + "license": [
  2673 + "MIT"
  2674 + ],
  2675 + "authors": [
  2676 + {
  2677 + "name": "Paul Duncan",
  2678 + "email": "pabs@pablotron.org"
  2679 + },
  2680 + {
  2681 + "name": "Jonatan Männchen",
  2682 + "email": "jonatan@maennchen.ch"
  2683 + },
  2684 + {
  2685 + "name": "Jesse Donat",
  2686 + "email": "donatj@gmail.com"
  2687 + },
  2688 + {
  2689 + "name": "András Kolesár",
  2690 + "email": "kolesar@kolesar.hu"
  2691 + }
  2692 + ],
  2693 + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
  2694 + "keywords": [
  2695 + "stream",
  2696 + "zip"
  2697 + ],
  2698 + "support": {
  2699 + "issues": "https://github.com/maennchen/ZipStream-PHP/issues",
  2700 + "source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.0"
  2701 + },
  2702 + "funding": [
  2703 + {
  2704 + "url": "https://github.com/maennchen",
  2705 + "type": "github"
  2706 + },
  2707 + {
  2708 + "url": "https://opencollective.com/zipstream",
  2709 + "type": "open_collective"
  2710 + }
  2711 + ],
  2712 + "time": "2023-06-21T14:59:35+00:00"
  2713 + },
  2714 + {
  2715 + "name": "markbaker/complex",
  2716 + "version": "3.0.2",
  2717 + "source": {
  2718 + "type": "git",
  2719 + "url": "https://github.com/MarkBaker/PHPComplex.git",
  2720 + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
  2721 + },
  2722 + "dist": {
  2723 + "type": "zip",
  2724 + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
  2725 + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
  2726 + "shasum": ""
  2727 + },
  2728 + "require": {
  2729 + "php": "^7.2 || ^8.0"
  2730 + },
  2731 + "require-dev": {
  2732 + "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
  2733 + "phpcompatibility/php-compatibility": "^9.3",
  2734 + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
  2735 + "squizlabs/php_codesniffer": "^3.7"
  2736 + },
  2737 + "type": "library",
  2738 + "autoload": {
  2739 + "psr-4": {
  2740 + "Complex\\": "classes/src/"
  2741 + }
  2742 + },
  2743 + "notification-url": "https://packagist.org/downloads/",
  2744 + "license": [
  2745 + "MIT"
  2746 + ],
  2747 + "authors": [
  2748 + {
  2749 + "name": "Mark Baker",
  2750 + "email": "mark@lange.demon.co.uk"
  2751 + }
  2752 + ],
  2753 + "description": "PHP Class for working with complex numbers",
  2754 + "homepage": "https://github.com/MarkBaker/PHPComplex",
  2755 + "keywords": [
  2756 + "complex",
  2757 + "mathematics"
  2758 + ],
  2759 + "support": {
  2760 + "issues": "https://github.com/MarkBaker/PHPComplex/issues",
  2761 + "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
  2762 + },
  2763 + "time": "2022-12-06T16:21:08+00:00"
  2764 + },
  2765 + {
  2766 + "name": "markbaker/matrix",
  2767 + "version": "3.0.1",
  2768 + "source": {
  2769 + "type": "git",
  2770 + "url": "https://github.com/MarkBaker/PHPMatrix.git",
  2771 + "reference": "728434227fe21be27ff6d86621a1b13107a2562c"
  2772 + },
  2773 + "dist": {
  2774 + "type": "zip",
  2775 + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
  2776 + "reference": "728434227fe21be27ff6d86621a1b13107a2562c",
  2777 + "shasum": ""
  2778 + },
  2779 + "require": {
  2780 + "php": "^7.1 || ^8.0"
  2781 + },
  2782 + "require-dev": {
  2783 + "dealerdirect/phpcodesniffer-composer-installer": "dev-master",
  2784 + "phpcompatibility/php-compatibility": "^9.3",
  2785 + "phpdocumentor/phpdocumentor": "2.*",
  2786 + "phploc/phploc": "^4.0",
  2787 + "phpmd/phpmd": "2.*",
  2788 + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
  2789 + "sebastian/phpcpd": "^4.0",
  2790 + "squizlabs/php_codesniffer": "^3.7"
  2791 + },
  2792 + "type": "library",
  2793 + "autoload": {
  2794 + "psr-4": {
  2795 + "Matrix\\": "classes/src/"
  2796 + }
  2797 + },
  2798 + "notification-url": "https://packagist.org/downloads/",
  2799 + "license": [
  2800 + "MIT"
  2801 + ],
  2802 + "authors": [
  2803 + {
  2804 + "name": "Mark Baker",
  2805 + "email": "mark@demon-angel.eu"
  2806 + }
  2807 + ],
  2808 + "description": "PHP Class for working with matrices",
  2809 + "homepage": "https://github.com/MarkBaker/PHPMatrix",
  2810 + "keywords": [
  2811 + "mathematics",
  2812 + "matrix",
  2813 + "vector"
  2814 + ],
  2815 + "support": {
  2816 + "issues": "https://github.com/MarkBaker/PHPMatrix/issues",
  2817 + "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
  2818 + },
  2819 + "time": "2022-12-02T22:17:43+00:00"
  2820 + },
  2821 + {
2573 2822 "name": "masterminds/html5",
2574 2823 "version": "2.8.0",
2575 2824 "source": {
... ... @@ -3132,6 +3381,111 @@
3132 3381 "time": "2023-02-08T01:06:31+00:00"
3133 3382 },
3134 3383 {
  3384 + "name": "phpoffice/phpspreadsheet",
  3385 + "version": "1.29.0",
  3386 + "source": {
  3387 + "type": "git",
  3388 + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
  3389 + "reference": "fde2ccf55eaef7e86021ff1acce26479160a0fa0"
  3390 + },
  3391 + "dist": {
  3392 + "type": "zip",
  3393 + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/fde2ccf55eaef7e86021ff1acce26479160a0fa0",
  3394 + "reference": "fde2ccf55eaef7e86021ff1acce26479160a0fa0",
  3395 + "shasum": ""
  3396 + },
  3397 + "require": {
  3398 + "ext-ctype": "*",
  3399 + "ext-dom": "*",
  3400 + "ext-fileinfo": "*",
  3401 + "ext-gd": "*",
  3402 + "ext-iconv": "*",
  3403 + "ext-libxml": "*",
  3404 + "ext-mbstring": "*",
  3405 + "ext-simplexml": "*",
  3406 + "ext-xml": "*",
  3407 + "ext-xmlreader": "*",
  3408 + "ext-xmlwriter": "*",
  3409 + "ext-zip": "*",
  3410 + "ext-zlib": "*",
  3411 + "ezyang/htmlpurifier": "^4.15",
  3412 + "maennchen/zipstream-php": "^2.1 || ^3.0",
  3413 + "markbaker/complex": "^3.0",
  3414 + "markbaker/matrix": "^3.0",
  3415 + "php": "^7.4 || ^8.0",
  3416 + "psr/http-client": "^1.0",
  3417 + "psr/http-factory": "^1.0",
  3418 + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
  3419 + },
  3420 + "require-dev": {
  3421 + "dealerdirect/phpcodesniffer-composer-installer": "dev-main",
  3422 + "dompdf/dompdf": "^1.0 || ^2.0",
  3423 + "friendsofphp/php-cs-fixer": "^3.2",
  3424 + "mitoteam/jpgraph": "^10.3",
  3425 + "mpdf/mpdf": "^8.1.1",
  3426 + "phpcompatibility/php-compatibility": "^9.3",
  3427 + "phpstan/phpstan": "^1.1",
  3428 + "phpstan/phpstan-phpunit": "^1.0",
  3429 + "phpunit/phpunit": "^8.5 || ^9.0 || ^10.0",
  3430 + "squizlabs/php_codesniffer": "^3.7",
  3431 + "tecnickcom/tcpdf": "^6.5"
  3432 + },
  3433 + "suggest": {
  3434 + "dompdf/dompdf": "Option for rendering PDF with PDF Writer",
  3435 + "ext-intl": "PHP Internationalization Functions",
  3436 + "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
  3437 + "mpdf/mpdf": "Option for rendering PDF with PDF Writer",
  3438 + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
  3439 + },
  3440 + "type": "library",
  3441 + "autoload": {
  3442 + "psr-4": {
  3443 + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
  3444 + }
  3445 + },
  3446 + "notification-url": "https://packagist.org/downloads/",
  3447 + "license": [
  3448 + "MIT"
  3449 + ],
  3450 + "authors": [
  3451 + {
  3452 + "name": "Maarten Balliauw",
  3453 + "homepage": "https://blog.maartenballiauw.be"
  3454 + },
  3455 + {
  3456 + "name": "Mark Baker",
  3457 + "homepage": "https://markbakeruk.net"
  3458 + },
  3459 + {
  3460 + "name": "Franck Lefevre",
  3461 + "homepage": "https://rootslabs.net"
  3462 + },
  3463 + {
  3464 + "name": "Erik Tilt"
  3465 + },
  3466 + {
  3467 + "name": "Adrien Crivelli"
  3468 + }
  3469 + ],
  3470 + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
  3471 + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
  3472 + "keywords": [
  3473 + "OpenXML",
  3474 + "excel",
  3475 + "gnumeric",
  3476 + "ods",
  3477 + "php",
  3478 + "spreadsheet",
  3479 + "xls",
  3480 + "xlsx"
  3481 + ],
  3482 + "support": {
  3483 + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
  3484 + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.0"
  3485 + },
  3486 + "time": "2023-06-14T22:48:31+00:00"
  3487 + },
  3488 + {
3135 3489 "name": "phpoption/phpoption",
3136 3490 "version": "1.9.1",
3137 3491 "source": {
public/hello_world.xlsx
No preview for this file type
... ... @@ -337,3 +337,5 @@ Route::post('ckeditor/upload', [CKEditorController::class, 'upload'])->name('cke
337 337 Route::get('pages/{pages:slug}', [PagesController::class, 'pages'])->name('page');
338 338  
339 339 Route::get('redis/', [PagesController::class, 'redis'])->name('redis');
  340 +
  341 +Route::get('excel/', [PagesController::class, 'excel'])->name('excel');