npm.io
1.0.0 • Published 6 months ago

@progress/kendo-csv

Licence
SEE LICENSE IN LICENSE.md
Version
1.0.0
Deps
0
Size
28 kB
Vulns
0
Weekly
0
Stars
240

kendo-csv

A lightweight, secure TypeScript library for generating CSV files from JavaScript data structures with built-in formula injection protection.

Features

  • Type-safe - Full TypeScript support with comprehensive type definitions
  • Secure - Built-in formula injection protection to prevent spreadsheet attacks
  • Flexible - Works with arrays, objects, and Maps
  • International - UTF-8 BOM support for proper Excel encoding
  • Lightweight - Zero dependencies for core functionality
  • Customizable - Configure delimiters, line endings, headers, and more

Installation

npm install @progress/kendo-csv

Quick Start

Generate CSV String
import { toCSV } from '@progress/kendo-csv';

const data = [
    { id: 1, name: "John Doe", email: "john@example.com" },
    { id: 2, name: "Jane Smith", email: "jane@example.com" }
];

const csv = toCSV({
    data,
    keys: ['id', 'name', 'email'],
    names: ['ID', 'Name', 'Email']
});

console.log(csv);
// Output:
// ID,Name,Email
// 1,John Doe,john@example.com
// 2,Jane Smith,jane@example.com
Create CSV Blob for Download
import { toCSVBlob } from '@progress/kendo-csv';
import { saveAs } from '@progress/kendo-file-saver';

const data = [
    { id: 1, name: "John Doe", email: "john@example.com" },
    { id: 2, name: "Jane Smith", email: "jane@example.com" }
];

const blob = toCSVBlob({
    data,
    keys: ['id', 'name', 'email'],
    names: ['ID', 'Name', 'Email']
});

saveAs(blob, 'employees.csv');

Documentation

  • API Documentation - Complete reference for all functions and options
  • Examples - Interactive examples demonstrating all features

License

See LICENSE.md for details.

Keywords