{"id":22125425,"url":"https://github.com/notadd/ngx-xlsx","last_synced_at":"2025-07-25T15:32:26.604Z","repository":{"id":33118269,"uuid":"147330761","full_name":"notadd/ngx-xlsx","owner":"notadd","description":"基于SheetJS/js-xlsx，Angular导入、导出Excel，支持单个或者多个工作表导出、支持自定义表头、支持自定义工作表名称。","archived":false,"fork":false,"pushed_at":"2023-01-07T02:27:40.000Z","size":3372,"stargazers_count":12,"open_issues_count":25,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-24T14:09:02.585Z","etag":null,"topics":["angular","excel-export"],"latest_commit_sha":null,"homepage":"https://notadd.github.io/ngx-xlsx/","language":"TypeScript","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/notadd.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":"2018-09-04T10:45:19.000Z","updated_at":"2022-03-02T14:39:10.000Z","dependencies_parsed_at":"2023-01-14T23:29:07.574Z","dependency_job_id":null,"html_url":"https://github.com/notadd/ngx-xlsx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notadd%2Fngx-xlsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notadd%2Fngx-xlsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notadd%2Fngx-xlsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notadd%2Fngx-xlsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notadd","download_url":"https://codeload.github.com/notadd/ngx-xlsx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227590943,"owners_count":17790560,"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":["angular","excel-export"],"created_at":"2024-12-01T16:20:51.575Z","updated_at":"2024-12-01T16:20:52.175Z","avatar_url":"https://github.com/notadd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ngx-xlsx\n\n基于[SheetJS/js-xlsx](https://github.com/SheetJS/js-xlsx)，Angular导入、导出Excel，支持单个或者多个工作表导出、支持自定义表头、支持自定义工作表名称。\n\n## How to use\n### step-1\n\n#### 安装`@notadd/ngx-xlsx`\n+ `npm install @notadd/ngx-xlsx -S` \n \n#### 安装依赖\n+ `npm install xlsx -S`\n+ `npm install file-saver -S`\n\n#### step-2\n\n+ 添加NgxXLSXModule到你的Angular Module\n\n```typescript\n  import { NgxXLSXModule } from '@notadd/ngx-xlsx';\n\n  @NgModule({\n    imports: [\n        ...\n        NgxXLSXModule\n    ],\n    declarations: [AppComponent],\n    bootstrap: [AppComponent]\n  })\n  export class AppModule { }\n```\n\n#### step-3\n\n+ 在你的component中引入 `NgxXLSXService`\n```typescript\n  import { NgxXLSXService } from '@notadd/ngx-xlsx';\n```\n\n#### step-4\n\n+ 注入service并在需要的地方调用导出方法 `exportAsExcelFile`\n+ 注入service并在需要的地方调用导入方法 `importForExcelFile`\n\n\n## `exportAsExcelFile` 方法\n\n## 参数\n\n|     参数名    |   类型   | 是否必填 | 默认值 |                                                                   说明                                                                  |\n|:-------------|:--------|:--------|:------|:---------------------------------------------------------------------------------------------------------------------------------------|\n| json          | any[]    | 必填     |        | 需要导出的数据json    多个工作表导出时数据为二维数组：`[[工作表1],[工作表2],[工作表三]]`    单个工作表导出时数据为一维数组：`[工作表1]` |\n| exportOptions | ExportOptions   | 非必填     |    {}    | 导出配置    |    \n\n## Interface\n\n```typescript\nexport interface ExportOptions {\n  /* 文件名， 默认为时间戳 */\n  fileName?: string;     \n\n  /* 表头，默认为 json 数组对象的 Object.keys, 长度必须与 json 数组对象的 Object.keys 长度相等 */\n  /* 多个工作表可以对应多个表头或单个表头，多个表头为二维数组，与多个工作表匹配 */\n  headers?: Array\u003cstring | Array\u003cstring\u003e\u003e;   \n\n  /* Excel 工作表名称，默认为 'sheet' +索引(从1开始) 多个工作表导出时长度必须与 json 数组长度相等 单个工作表导出时长度必须等于1 */   \n  sheetNames?: Array\u003cstring\u003e;\n\n  /* 需要合并单元格的数组，['A1:B1'] 和 [['0,0', '0,1']] 等效，两种写法都支持 */\n  merges?: Array\u003cstring | Array\u003cstring\u003e\u003e;\n}\n```\n\n## `importForExcelFile` 方法\n\n## 参数\n\n|     参数名    |   类型   | 是否必填 | 默认值 |                                                                   说明                                                                  |\n|:-------------|:--------|:--------|:------|:---------------------------------------------------------------------------------------------------------------------------------------|\n| file          | File    | 必填     |        | 需要导入的 Excel 文件对象 |\n| importOptions | ImportOptions   | 非必填     |    {}    | 导入配置    |    \n\n## Interface\n\n```typescript\nexport interface ImportOptions {\n  /* 表头行数，默认为1，当 `headerKeys` 不为 `[]` 时导入的数据会按表头行数截取数组 */\n  headerRows?: number;   \n\n  /* Excel 表头对应的导入 `json` 的 `key`，默认为 Excel 表头 */\n  /* 多个工作表可以对应多个`key`数组或单个`key`数组，多个`key`数组为二维数组 */\n  headerKeys?: Array\u003cstring | Array\u003cstring\u003e\u003e;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotadd%2Fngx-xlsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotadd%2Fngx-xlsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotadd%2Fngx-xlsx/lists"}