Advanced, customizable, Optimized ,Minimal, light-weight Angular ratings.
rm-ng-export-to-csv
is a lightweight, dependency-free Angular library that enables developers to export JSON data as CSV files with just one function call. This library is designed to be highly customizable, performant, tree-shakable, and works seamlessly across all major platforms and browsers.
If you like this plugin, please give it a star ⭐.
✅ Supports custom CSV headers
✅ Compatible with all major browsers (Chrome, Firefox, Safari, Edge, iOS, Android)
✅ Mobile & tablet friendly
✅ Zero dependencies
✅ Tree-shakable and optimized for Angular CLI builds
✅ Ideal for chart libraries like Chart.js, Plotly, ApexCharts, and more
Install the library via npm:
npm install rm-ng-export-to-csv --save
Ensure your Angular version is 14 or higher.
import { RmNgExportToCsvService } from 'rm-ng-export-to-csv';
constructor(private exportCsv: RmNgExportToCsvService) {}
OR
private readonly exportCsv: RmNgExportToCsvService = inject(RmNgExportToCsvService);
const data = [
{ name: 'Alice', age: 28, city: 'New York' },
{ name: 'Bob', age: 35, city: 'Chicago' }
];
this.exportCsv.exportAsCSV(data, 'users.csv');
const data = [
{ name: 'Alice', age: 28, city: 'New York' },
{ name: 'Bob', age: 35, city: 'Chicago' }
];
const headers = [
{ label: 'Full Name', key: 'name' },
{ label: 'Age (Years)', key: 'age' },
{ label: 'City', key: 'city' }
];
this.exportCsv.exportAsCSV(data, 'users.csv', headers);
Version | Ng |
---|---|
1.x.x | 18.x |
2.x.x | 19.x |
3.x.x | 20.x |
Parameter | Type | Required | Description |
---|---|---|---|
data |
Record<string, any>[] |
✅ | JSON data array to export |
filename |
string |
❌ | Optional filename (default: export.csv ) |
headers |
CsvHeaderMapping[] |
❌ | Optional mapping of labels and keys |
interface CsvHeaderMapping {
label: string; // Column name in the CSV file
key: string; // Corresponding key in the JSON data
}
- ✅ Export any JSON array to CSV
- ✅ Customizable column headers
- ✅ Column-to-key mapping support
- ✅ Auto-download in all browsers (desktop and mobile)
- ✅ Compatible with Angular CLI and Nx
- ✅ Small bundle size, no runtime dependencies
- ✅ Fully typed and framework-compliant
Tested on the latest versions of:
- ✅ Google Chrome
- ✅ Mozilla Firefox
- ✅ Apple Safari (macOS and iOS)
- ✅ Microsoft Edge
- ✅ Android Chrome Browser
- ✅ iOS Safari on iPhone & iPad
Supports both desktop and mobile auto-download behavior.
MIT License. Feel free to use, modify, and contribute.
If you identify any errors in this component, or have an idea for an improvement, please open an issue. I am excited to see what the community thinks of this project, and I would love your input!
Rajat Malik
Contributions are welcome! If you have ideas, suggestions, or improvements, feel free to open issues or pull requests.
- XLSX export support
- Flattening nested JSON structures
- Column filtering and ordering
- Internationalization (i18n) support for headers
- UI component to preview before export