{"id":26107134,"url":"https://github.com/francosuarez-dev/tt-export-to-csv","last_synced_at":"2026-05-03T07:41:50.124Z","repository":{"id":253471719,"uuid":"843607653","full_name":"francosuarez-dev/tt-export-to-csv","owner":"francosuarez-dev","description":"TanStack Table Export to CSV","archived":false,"fork":false,"pushed_at":"2024-08-17T07:30:25.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-23T02:57:38.062Z","etag":null,"topics":["react","tanstack-table"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francosuarez-dev.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-08-16T22:45:42.000Z","updated_at":"2025-09-02T19:17:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"03b7c62d-fbfb-45e0-b829-f23b8d887146","html_url":"https://github.com/francosuarez-dev/tt-export-to-csv","commit_stats":null,"previous_names":["francosuarez-dev/tt-export-to-csv"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/francosuarez-dev/tt-export-to-csv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosuarez-dev%2Ftt-export-to-csv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosuarez-dev%2Ftt-export-to-csv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosuarez-dev%2Ftt-export-to-csv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosuarez-dev%2Ftt-export-to-csv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francosuarez-dev","download_url":"https://codeload.github.com/francosuarez-dev/tt-export-to-csv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosuarez-dev%2Ftt-export-to-csv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32562118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["react","tanstack-table"],"created_at":"2025-03-09T22:43:25.890Z","updated_at":"2026-05-03T07:41:50.118Z","avatar_url":"https://github.com/francosuarez-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# TanStack Table Export to CSV\n\nThis library provides a function to export data from a TanStack table to a CSV file.\n\n\n## Installation\n\n```bash\n  npm i tt-export-to-csv\n```\nor\n```bash\n  yarn add tt-export-to-csv\n```\n\n## Dependencies\n\nThis library has the following dependencies:\n\n- `papaparse`: To handle data conversion to CSV format. It must be installed in your project for the library to work correctly.\n\nPuedes instalar `papaparse` usando `npm` o `yarn`:\n```bash\n  npm install papaparse\n```\n```bash\n  yarn add papaparse\n```\n\n## Usage\n\n### `exportToCsv`\nThe main function of the library is `exportToCsv`, which allows you to export the table data to a CSV file.\n\n## Parámetros:\n\n- **filename**: The name of the CSV file to be generated.\n\n- **headers**: An array of `Header` objects that defines the table headers.\n\n- **rows**: An array of `Row` objects containing the table data.\n\n- **original** (optional): If specified as `true`, a CSV will be generated with the original data according to the interface used to define the columns. If not specified, the CSV will be created from `headers` and `rows`.\n\n### Column Customization:\n\nYou can customize the column export using the meta property in the column definition. The `exportCsvString` property allows you to define a string that will be used to customize the exported content. You can use ${variable}\n\n```javascript\n...\n  meta: {\n        exportCsvString: '${name} more string' // allows you to define a string that will be used to customize the exported content. You can use ${variable} to insert values ​​obtained from getValue.\n      }\n...\n```\n### Example:\n\n```javascript\nimport {\n  columnDef,\n  getFilteredRowModel,\n  useReactTable,\n} from \"@tanstack/react-table\";\nimport { exportToCsv } from 'tt-export-to-csv'\n\ntype User = {\n  id: string;\n  first-name: string;\n  last-name: string;\n  active: boolean;\n};\n\nconst columnHelper = createColumnHelper\u003cUser\u003e();\n\nconst UserColumns: ColumnDef\u003cUser\u003e[] = [\n  {\n    id: 'name',\n    header: 'Name',\n    accesorFn: row =\u003e ({ name: row.first-name, lastName: row.last-name id: row.id}),\n    cell: info =\u003e {\n      const { name, lastName, id } = info.getValue() as {name: string, lastName: string, id: number};\n      return (\n        \u003ca href={`/user/profile/${id}`}\u003e\n          \u003cspan\u003e\n          {`${name}-${lastName}`}\n          \u003c/span\u003e\n        \u003c/a\u003e\n      )\n    },\n    meta: {\n      exportCsvString: '${name}' // allows you to define a string that will be used to customize the exported content. You can use ${variable} to insert values ​​obtained from getValue.\n    }\n  },\n  {\n    id: 'state',\n    header: 'State',\n    accesorKey: 'active'\n  }\n]\n\nconst App: React.FC = () =\u003e {\n\n  const [data, setData] = React.useState(() =\u003e [...defaultData]);\n\n  const table = useReactTable({\n    data,\n    columns,\n    getCoreRowModel: getCoreRowModel(),\n  });\n\n  const handleExportToCsv = (): void =\u003e {\n    const headers = table\n      .getHeaderGroups()\n      .map((x) =\u003e x.headers)\n      .flat();\n\n    const rows = table.getCoreRowModel().rows; // All Rows\n    const rows = table.getSelectedRowModel().rows; // Selected rows\n\n    exportToCsv('users.csv', headers, rows);\n  };\n\n  return(\n    \u003c\u003e\n      \u003cbutton onClick={handleExportToCsv}\u003eExport to csv\u003c/button\u003e\n    \u003c/\u003e\n  )\n}\n\n```\n\n\n## License\n\n[GNU GPLv3](https://choosealicense.com/licenses/gpl-3.0/)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancosuarez-dev%2Ftt-export-to-csv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancosuarez-dev%2Ftt-export-to-csv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancosuarez-dev%2Ftt-export-to-csv/lists"}