npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@molteni/export-csv

v0.0.8

Published

Quick and simply export JSON and tables data to CSV

Downloads

1,230

Readme

export-csv

Blog - article

https://marco.dev/2017/03/05/angular-and-javascript-export-your-data-to-csv-using-typescript/ Image of export

Example

Goal - Export your web table to Excel in a click

Many js applications show tables and data. Very often the business users need the possibility to export their data in excel. Most of the time a simple export (no server required) is enough.

Description

This package easily export to the CSV the content of an array of objects (JavaScript or JSON, e.g. table of data on the screen) to a format compatible with Excel.

The generated document is in UTF-8 with BOF. This allows the characters to be correctly showed in Excel.

Features

  • The library has been written in Typescript and target Angular (1.x, >=2).
  • It is possible to decide which columns export and in which order.
  • UTF-8 supported

Installation

npm i @molteni/export-csv --save

or add to your package.json in the 'dependencies' : "@molteni/export-csv": "^0.0.3",

Mime

Until version 0.0.6 the mime used is text\plain. From version 0.0.7 the mime type is text\csv.

Usage

In Angular import the library with: import {ExportToCSV} from "@molteni/export-csv";

Use the library:

Export only one specific columns

exportColumnsToCSV(JSONListItemsToPublish : any[], fileName : string, columns : string[]);

exporter = new ExportToCSV();
exporter.exportColumnsToCSV(this.blogArticles, "filename", ["title"])
exporter = new ExportToCSV();
objectToExport = [{column : 'äàü£™ , ®, ©,'}, {column: 'second row'}];
exporter.exportColumnsToCSV(objectToExport, "filename", ["column"])

Export all the columns

exportAllToCSV(JSONListItemsToPublish : any[], fileName : string);

var exporter = new ExportToCSV();
exporter.exportColumnsToCSV(this.blogArticles, "filename")

Configure the character to use as separator

By default the character ';' is used for the generation of the file. E.g.:

1;Test

If you need to generate the file with a different separator you can pass it as parameter, e.g.:

var exporter = new ExportToCSV();
exporter.exportColumnsToCSV(this.blogArticles, 'filename', {separator: ','});

The generated file will use the defined separator, e.g.:

1,Test