{"id":24976009,"url":"https://github.com/ogenes/exceler","last_synced_at":"2025-04-11T13:08:22.674Z","repository":{"id":40611901,"uuid":"504541205","full_name":"ogenes/exceler","owner":"ogenes","description":"封装 phpspreadsheet 工具类","archived":false,"fork":false,"pushed_at":"2024-01-19T10:36:01.000Z","size":157,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T21:15:32.547Z","etag":null,"topics":["excel","excel-export","office","php","phpexcel","phpoffice","phpspreadsheet","spreadsheet"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ogenes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-06-17T13:16:43.000Z","updated_at":"2024-09-27T22:44:21.000Z","dependencies_parsed_at":"2024-01-19T11:29:54.853Z","dependency_job_id":"e0ca3d5f-15d4-4d7e-8a4e-9e58d1a64056","html_url":"https://github.com/ogenes/exceler","commit_stats":{"total_commits":22,"total_committers":3,"mean_commits":7.333333333333333,"dds":0.2272727272727273,"last_synced_commit":"e2e2ad41310569f73c93bf759612f6a84ba61054"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ogenes%2Fexceler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ogenes%2Fexceler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ogenes%2Fexceler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ogenes%2Fexceler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ogenes","download_url":"https://codeload.github.com/ogenes/exceler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248404656,"owners_count":21097791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["excel","excel-export","office","php","phpexcel","phpoffice","phpspreadsheet","spreadsheet"],"created_at":"2025-02-03T21:59:15.792Z","updated_at":"2025-04-11T13:08:22.631Z","avatar_url":"https://github.com/ogenes.png","language":"PHP","readme":"# exceler\n封装 phpspreadsheet 工具类\n\n## 安装\n```shell\ncomposer require ogenes/exceler\n```\n\n## 文档\n\n[wiki](https://github.com/ogenes/exceler/wiki)\n\n## 简单读取\n```php\n    $config['sheet1'] = [\n        'goodsName' =\u003e '商品名称',\n        'color' =\u003e '颜色',\n        'price' =\u003e '售价',\n        'actualStock' =\u003e '实际库存',\n    ];\n    $filepath = __DIR__ . '/file/example.xlsx';\n    return ExcelClient::getInstance()-\u003eread($filepath, $config);\n```\n\n## DEMO\n\n```php\n## 可以再次封装定义企业内的Excel固定模板，\nclass ExcelHelper\n{\n    public static function export(array $data, array $config, string $filename): string\n    {\n        $client = ExportClient::getInstance();\n        $fill = [\n            'fillType' =\u003e Fill::FILL_GRADIENT_LINEAR,\n            'startColor' =\u003e [\n                'argb' =\u003e 'FFFE00',\n            ],\n            'endColor' =\u003e [\n                'argb' =\u003e 'FFFE00',\n            ]\n        ];\n        $client-\u003esetStyleHeaderFont([\n                'name' =\u003e '宋体',\n                'size' =\u003e 11,\n                'bold' =\u003e true,\n                'color' =\u003e ['argb' =\u003e '000000'],\n            ])\n            -\u003esetStyleFont([\n                'name' =\u003e '宋体',\n                'size' =\u003e 10,\n                'color' =\u003e ['argb' =\u003e '000000'],\n            ])\n            -\u003esetStyleHeaderFill($fill);\n        \n        $client-\u003esetFreezeHeader(true);\n       \treturn $client-\u003esetFilepath(storage_path('excel') . date('/Y/m/d/'))\n                -\u003esetFilename($filename)\n                -\u003esetData($data)\n                -\u003esetConfig($config)\n                -\u003eexport();\n    }\n    \n}\n```\n\n```php\n## 导出时定义好config即可。\n\n$data['sheet1'] = $list;\n\n$config['sheet1'] = [\n  ['bindKey' =\u003e 'orderId', 'columnName' =\u003e '订单ID', 'width' =\u003e 20, 'align' =\u003e Alignment::HORIZONTAL_RIGHT],\n  ['bindKey' =\u003e 'withdrawDate', 'columnName' =\u003e '交易日期', 'width' =\u003e 15, 'align' =\u003e Alignment::HORIZONTAL_LEFT],\n  ['bindKey' =\u003e 'statusCn', 'columnName' =\u003e '订单状态', 'width' =\u003e 10, 'align' =\u003e Alignment::HORIZONTAL_LEFT],\n  ['bindKey' =\u003e 'amount', 'columnName' =\u003e '订单金额(USD)', 'width' =\u003e 18, 'align' =\u003e Alignment::HORIZONTAL_RIGHT, 'format' =\u003e NumberFormat::FORMAT_NUMBER_00],\n  ['bindKey' =\u003e 'cost', 'columnName' =\u003e '成本(USD)', 'width' =\u003e 18, 'align' =\u003e Alignment::HORIZONTAL_RIGHT, 'format' =\u003e NumberFormat::FORMAT_NUMBER_00],\n  ['bindKey' =\u003e '={amount}-{cost}', 'columnName' =\u003e '收入(USD)', 'width' =\u003e 18, 'align' =\u003e Alignment::HORIZONTAL_RIGHT, 'format' =\u003e NumberFormat::FORMAT_NUMBER_00],\n  ['bindKey' =\u003e '=({amount}-{cost})/{amount}', 'columnName' =\u003e '毛利率', 'width' =\u003e 18, 'align' =\u003e Alignment::HORIZONTAL_RIGHT, 'format' =\u003e NumberFormat::FORMAT_PERCENTAGE_00],\n  ['bindKey' =\u003e 'uid', 'columnName' =\u003e '用户ID', 'width' =\u003e 30, 'align' =\u003e Alignment::HORIZONTAL_RIGHT],\n  ['bindKey' =\u003e 'username', 'columnName' =\u003e '用户名', 'width' =\u003e 30, 'align' =\u003e Alignment::HORIZONTAL_LEFT],\n  ['bindKey' =\u003e 'note', 'columnName' =\u003e '备注', 'width' =\u003e 30, 'align' =\u003e Alignment::HORIZONTAL_LEFT],\n\n];\n$filename = \"收支明细\" . date('YmdHis') . '.xlsx';\n$fileFullpath = ExcelHelper::export($data, $config, $filename);\n\n```\n\n![image-20220630132744221](https://ogenes.oss-cn-beijing.aliyuncs.com/img/2022/202206301327293.png)\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fogenes%2Fexceler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fogenes%2Fexceler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fogenes%2Fexceler/lists"}