{"id":20144175,"url":"https://github.com/quansitech/qs-excel","last_synced_at":"2026-05-10T18:57:09.073Z","repository":{"id":36472332,"uuid":"227019389","full_name":"quansitech/qs-excel","owner":"quansitech","description":"easy to generate and load excel data for qs bussiness","archived":false,"fork":false,"pushed_at":"2022-04-19T09:25:47.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T10:50:10.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quansitech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-10T03:17:28.000Z","updated_at":"2022-03-17T01:20:47.000Z","dependencies_parsed_at":"2022-08-08T15:01:27.182Z","dependency_job_id":null,"html_url":"https://github.com/quansitech/qs-excel","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqs-excel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqs-excel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqs-excel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quansitech%2Fqs-excel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quansitech","download_url":"https://codeload.github.com/quansitech/qs-excel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241587914,"owners_count":19986627,"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":[],"created_at":"2024-11-13T22:09:04.075Z","updated_at":"2026-05-10T18:57:04.020Z","avatar_url":"https://github.com/quansitech.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"### 安装\n```php\ncomposer require tiderjian/qs-excel\n```\n\n### 介绍\nExcel文件生成及Excel文件读取\n\n### 用法\n\n#### ListBuilder\n\n+ 生成单个sheet的excel文件\n```php\n$options  = [\n    'row_count' =\u003e 500,    //excel生成的行数\n    'headers' =\u003e [\n        [\n            'title' =\u003e '读者编号',\n        ],\n        [\n            'title' =\u003e '姓名',\n        ],\n        [\n            'title' =\u003e '性别',\n            'type' =\u003e 'list',\n            'data_source' =\u003e '女,男'\n        ],\n        [\n            'title' =\u003e '读者类型',\n            'type' =\u003e 'list',\n            'data_source' =\u003e '高年级学生,低年级学生,老师'\n        ],\n        [\n            'title' =\u003e '读者状态',\n            'type' =\u003e 'list',\n            'data_source' =\u003e '停用,正常,注销,挂失'\n        ],\n        [\n            'title' =\u003e '注册日期'\n        ],\n        [\n            'title' =\u003e '学号'\n        ]\n    ]\n];\n\n//列表数据\n//次序与类型必须与options对应\n$data = [\n    'DD123456',\n    '张三',\n    '女',\n    '高年级学生',\n    '停用',\n    '2016-07-10',\n    'G44532220060903492X'\n];\n$excel = new \\QsExcel\\Excel();\n$excel-\u003eaddBuild(new \\QsExcel\\Builder\\ListBuilder($options, $data));\n$excel-\u003eoutput('reader_import.xlsx');\n\n```\n\n+ 生成多个sheet的excel文件\n```php\n//大数组数据，总字符串长度超过565，将会自动生成数据源sheet进行存储\n$project_arrs = [\n    .\n    .\n    .\n];\n\n$book_arrs = [\n    .\n    .\n    .\n];\n\n$options  = [\n    'row_count' =\u003e 500,\n    'headers' =\u003e [\n        [\n            'title' =\u003e '读者编号',\n        ],\n        [\n            'title' =\u003e '姓名',\n        ],\n        [\n            'title' =\u003e '性别',\n            'type' =\u003e 'list',\n            'data_source' =\u003e '女,男'\n        ],\n        [\n            'title' =\u003e '项目',\n            'type' =\u003e 'list',\n            'data_source' =\u003e implode(',', $project_arrs)\n        ],\n        [\n            'title' =\u003e '推荐书籍',\n            'type' =\u003e 'list',\n            'data_source' =\u003e implode(',', $book_arrs)\n        ],\n        [\n            'title' =\u003e '注册日期'\n        ],\n        [\n            'title' =\u003e '学号'\n        ]\n    ]\n];\n\n$options1  = [\n    'row_count' =\u003e 500,\n    'headers' =\u003e [\n        [\n            'title' =\u003e '读者姓名',\n        ],\n        [\n            'title' =\u003e '学校',\n        ],\n        [\n            'title' =\u003e '性别',\n            'type' =\u003e 'list',\n            'data_source' =\u003e '女,男'\n        ],\n        [\n            'title' =\u003e '项目',\n            'type' =\u003e 'list',\n            'data_source' =\u003e implode(',', $project_arrs)\n        ],\n        [\n            'title' =\u003e '注册日期'\n        ],\n        [\n            'title' =\u003e '学号'\n        ]\n    ]\n];\n\n$excel = new \\QsExcel\\Excel();\n$excel-\u003eaddBuild((new \\QsExcel\\ListBuilder($options))-\u003esetSheetName('test'));\n$excel-\u003eaddBuild((new \\QsExcel\\ListBuilder($options1))-\u003esetSheetName('test1'));\n$excel-\u003eoutput('reader_import.xlsx');\n\n```\n\n##### Cell Type\n\n+ ListTypeBuilder 将单元格设置成下拉列表,支持三种设置数据源的方式\n\n\u003e 1. 短字符串\n\u003e\u003e 短字符串的含义是小于565个字符，此时短字符串会直接设置为列表数据源，不会有额外的表格内容占用, 内容用\",\"分隔。\n```php\n[\n    'title' =\u003e '性别',\n    'type' =\u003e QsExcel\\Builder\\ListBuilder::LIST_TYPE,\n    'data_source' =\u003e '男,女'\n];\n```\n\n\u003e 2. 长字符串\n\u003e\u003e 长字符串是相对于短字符串而言的，也就是大于565个字符，此时qs-excel会自动生成一个名字为ListSource的sheet用于存放数据源\n```php\n$arr = []; //大数组\n[\n    'title' =\u003e '性别',\n    'type' =\u003e QsExcel\\Builder\\ListBuilder::LIST_TYPE,\n    'data_source' =\u003e implode(',', $arr)\n];\n```\n\n\u003e 3. 指定引用源\n\u003e\u003e qs-excel 支持以 \"sheet!$A$1:$A$20\" 这种格式的方式设置任意表格的引用数据源\n```php\n[\n    'title' =\u003e '团队名',\n    'type' =\u003e QsExcel\\Builder\\ListBuilder::LIST_TYPE,\n    'data_source' =\u003e '团队信息!$B$2:$B$500'   // 团队信息为其他sheet的sheet名，前后两个列字母的必须一致，这个例子就是B\n];\n```\n\n+ DateTypeBuilder 将单元格设置成日期格式\n```php\n[\n    'title' =\u003e '出生日期',\n    'type' =\u003e QsExcel\\Builder\\ListBuilder::DATE_TYPE\n];\n```\n\n+ MultiListTypeBuilder 多选类型\n\n    该类型不会对数据进行准确性校验，只会在ListSource sheet增加可选的值\n```php\n$arr = [ '标签1', '标签2', ...];\n[\n    'title' =\u003e '标签',\n    'type' =\u003e QsExcel\\Builder\\ListBuilder::MULTI_LIST_TYPE,\n    'data_source' =\u003e implode(',', $arr)\n];\n```\n\n####  ListLoader\n```php\n$file = __DIR__ . '/excel.xls';  \n$excel = new Excel();\n//需要读取多少个sheet的数据，则设置多少个loader，可根据不同的sheet类型来针对性的设置不同的loader类型\n//默认第一个loader读取index为0的sheet 第二个读取index为1的sheet，以此类推\n$excel-\u003esetLoadFile($file);\n$excel-\u003eaddLoader(new ListLoader());\n$excel-\u003eaddLoader(new ListLoader());\n$excel-\u003eaddLoader(new ListLoader());\n$excel-\u003eaddLoader(new ListLoader());\n$list = $excel-\u003eload(); \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquansitech%2Fqs-excel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquansitech%2Fqs-excel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquansitech%2Fqs-excel/lists"}