Socket
Book a DemoInstallSign in
Socket

rm-ng-export-to-csv

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rm-ng-export-to-csv

A lightweight and customizable Angular library to export JSON data to CSV files with auto-download support. Ideal for charts, tables, reports, and dashboards.

latest
Source
npmnpm
Version
3.0.0
Version published
Maintainers
1
Created
Source

Angular Export To Csv

Advanced, customizable, Optimized ,Minimal, light-weight Angular ratings.

npm License

rm-ng-export-to-csv

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

📦 Installation

Install the library via npm:

  npm install rm-ng-export-to-csv --save

Ensure your Angular version is 14 or higher.

🔧 Usage

Step 1: Import the Service

import { RmNgExportToCsvService } from 'rm-ng-export-to-csv';

Step 2: Inject into your Component or Service

constructor(private exportCsv: RmNgExportToCsvService) {}

OR

private readonly exportCsv: RmNgExportToCsvService = inject(RmNgExportToCsvService);

Step 3: Export with Default Headers

const data = [
  { name: 'Alice', age: 28, city: 'New York' },
  { name: 'Bob', age: 35, city: 'Chicago' }
];

this.exportCsv.exportAsCSV(data, 'users.csv');

Step 4: Export with Custom Headers and Mapping

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 Mapping

VersionNg
1.x.x18.x
2.x.x19.x
3.x.x20.x

🧪 API Reference

exportAsCSV(data, filename?, headers?)

ParameterTypeRequiredDescription
dataRecord<string, any>[]JSON data array to export
filenamestringOptional filename (default: export.csv)
headersCsvHeaderMapping[]Optional mapping of labels and keys

CsvHeaderMapping Interface

interface CsvHeaderMapping {
  label: string; // Column name in the CSV file
  key: string;   // Corresponding key in the JSON data
}

🚀 Features

  • ✅ 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

🌐 Browser Compatibility

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.

📄 License

MIT License. Feel free to use, modify, and contribute.

🐞 Issues

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!

👤 Author

Rajat Malik

🙌 Contributions

Contributions are welcome! If you have ideas, suggestions, or improvements, feel free to open issues or pull requests.

📌 Coming Soon

  • XLSX export support
  • Flattening nested JSON structures
  • Column filtering and ordering
  • Internationalization (i18n) support for headers
  • UI component to preview before export

Keywords

angular

FAQs

Package last updated on 27 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts