{"id":13808937,"url":"https://github.com/rars/ng2csv","last_synced_at":"2025-04-12T20:52:22.175Z","repository":{"id":53172783,"uuid":"97054920","full_name":"rars/ng2csv","owner":"rars","description":"Angular service for saving data to CSV file.","archived":false,"fork":false,"pushed_at":"2024-12-06T11:47:32.000Z","size":2692,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T20:52:17.118Z","etag":null,"topics":["angular","angular2","csv"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/rars.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-12T21:51:13.000Z","updated_at":"2024-12-06T11:46:28.000Z","dependencies_parsed_at":"2023-02-17T23:45:19.989Z","dependency_job_id":"60a9f904-88de-4631-b882-9ff0a27f138d","html_url":"https://github.com/rars/ng2csv","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rars%2Fng2csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rars%2Fng2csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rars%2Fng2csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rars%2Fng2csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rars","download_url":"https://codeload.github.com/rars/ng2csv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631728,"owners_count":21136560,"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","angular2","csv"],"created_at":"2024-08-04T01:01:55.569Z","updated_at":"2025-04-12T20:52:22.154Z","avatar_url":"https://github.com/rars.png","language":"TypeScript","readme":"# ng2csv\n\n[![Node.js CI](https://github.com/rars/ng2csv/actions/workflows/node.js.yml/badge.svg)](https://github.com/rars/ng2csv/actions/workflows/node.js.yml)\n\nAngular module for saving CSV files.\n\n## Quickstart\n\n1. Install `file-saver` and `ng2csv` modules from npm:\n   ```\n   npm install file-saver ng2csv --save\n   ```\n2. Import `Ng2CsvModule` to your app:\n\n   ```\n   import { BrowserModule } from '@angular/platform-browser';\n   import { NgModule } from '@angular/core';\n   import { Ng2CsvModule } from 'ng2csv';\n   import { AppComponent } from './app.component';\n\n   @NgModule({\n     declarations: [\n       AppComponent\n     ],\n     imports: [\n       BrowserModule,\n       Ng2CsvModule\n     ],\n     providers: [],\n     bootstrap: [AppComponent]\n   })\n   export class AppModule { }\n   ```\n\n3. Inject the `Ng2CsvService` into your component:\n\n   ```\n   import { Component } from '@angular/core';\n   import { Ng2CsvService } from 'ng2csv';\n\n   @Component({\n     selector: 'app-root',\n     templateUrl: './app.component.html',\n     styleUrls: ['./app.component.css'],\n     providers: [Ng2CsvService]\n   })\n   export class AppComponent {\n     public constructor(private ng2Csv: Ng2CsvService) {}\n\n     public download(): void {\n       this.ng2Csv.download([\n           {\n             id: 1,\n             name: 'Alice'\n           },\n           {\n             id: 2,\n             name: 'Bob'\n           }\n         ],\n         'names.csv');\n     }\n   }\n   ```\n\n## Configuration\n\n### Auto mapping\n\nUnless specified, an automatic mapping is used from the data to columns. It does this by looking at the properties available on the object and then enumerating them, one column for each, and using the `.toString()` method to serialise the values to the CSV data.\n\n### Row headers and ordering\n\nYou can output a subset of the data's properties to CSV by defining your own custom mapping. This allows you to specify the order columns are written in and what value is written for each row in each column.\n\n```\nimport { OrderedProjectionCsvRowMapper } from 'ng2csv';\n// ...\nconst rowMapper = new OrderedProjectionCsvRowMapper\u003cMyType\u003e([\n    ['First Name', x =\u003e x.Name],\n    ['Identifier', x =\u003e 'N' + x.Id.toString()]\n]);\nthis.ng2Csv.download(myData, 'file.csv', rowMapper);\n/*\n Generates CSV:\n \"First Name\",\"Identifier\"\n Alice,N1\n Bob,N2\n */\n```\n\n### Delimiters, header row\n\nYou can control what character is used to separate columns (e.g. to use ';' or tab separators rather than ',') and whether to include a header row.\n\n```\nimport { CsvConfiguration } from 'ng2csv';\n// ...\nconst csvConfig = new CsvConfiguration();\ncsvConfig.delimiter = '\\t';\ncsvConfig.includeHeaderRow = false;\nthis.ng2Csv.download(myData, 'file.csv', undefined, csvConfig);\n```\n\n### Null or undefined values\n\nYou can control how `null` or `undefined` values are written out in config.\n\n```\nimport { CsvConfiguration } from 'ng2csv';\n// ...\nconst csvConfig = new CsvConfiguration();\ncsvConfig.outputValueForNull = 'NULL';\ncsvConfig.outputValueForUndefined = 'UNDEFINED';\n```\n\n## Contributions welcome!\n\nIf you have a feature or improvement you would like to see included, please raise an issue or a PR and I will review.\n\n## License\n\nSee the [LICENSE](LICENSE) file for license rights and limitations (MIT).\n","funding_links":[],"categories":["Third Party Components"],"sub_categories":["CSV"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frars%2Fng2csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frars%2Fng2csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frars%2Fng2csv/lists"}