Skip to content

Commit

Permalink
version 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LCluber committed Nov 16, 2020
2 parents b166966 + c1276a8 commit 06d6a3b
Show file tree
Hide file tree
Showing 11 changed files with 312 additions and 521 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 0.2.0 (November 17th 2020)
-----------------------------
* Added support for array of different objects

Version 0.1.11 (April 10th 2020)
-----------------------------
* Fixed csv export with custom labels on Firefox

Version 0.1.10 (April 10th 2019)
-----------------------------
* Fixed csv export with better filename checking
Expand Down
59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ The main purpose of this library is to provide an easy way to export your data a

## Installation

### npm

```bash
$ npm i @lcluber/csvxjs
```

### yarn

```bash
$ npm install @lcluber/csvxjs
$ yarn add @lcluber/csvxjs
```
Or download it **[here](http://csvxjs.lcluber.com/#download)**.

## Usage

Expand All @@ -29,27 +36,34 @@ import { Export, Convert } from '@lcluber/csvxjs';
let array = [
{
firstname:'Galileo',
lastname:'Galilei',
lastname:'Galiléi',
born:1564,
died:1642
},
{
firstname:'Nikola',
lastname:'Tesla',
city:'Smiljan',
born:1856,
died:1943
},
{
firstname:'Albert',
lastname:'Einstein',
born:1879,
lastname:'Einstein',
died:1955
}
];

let customLabels = {
firstname: 'First name',
lastname: 'Last name',
city: 'City',
born: 'Born',
died: 'Died'
};
let exportButton = document.getElementById('csv');
exportButton.addEventListener('click', function() {
Export.data('scientists',array,{separator: ';'});// ; separator for excel friendly imports
Export.data('scientists',array,{separator: ';', customLabels: customLabels});// ; separator for excel friendly imports
});

// Convert CSV data to HTML table
Expand All @@ -73,29 +87,36 @@ document.getElementById("table").innerHTML = Convert.table(data,{separator: ';'}

// Convert an array to CSV file
var array = [
{
{
firstname:'Galileo',
lastname:'Galilei',
lastname:'Galiléi',
born:1564,
died:1642
},
{
firstname:'Nikola',
lastname:'Tesla',
city:'Smiljan',
born:1856,
died:1943
},
{
firstname:'Albert',
lastname:'Einstein',
born:1879,
lastname:'Einstein',
died:1955
}
];

var customLabels = {
firstname: 'First name',
lastname: 'Last name',
city: 'City',
born: 'Born',
died: 'Died'
};
var exportButton = document.getElementById('csv');
exportButton.addEventListener('click', function() {
CSVx.Export.data('scientists',array,{separator: ';'});// ; separator for excel friendly imports
CSVx.Export.data('scientists',array,{separator: ';', customLabels: customLabels});// ; separator for excel friendly imports
});

// Convert CSV data to HTML table
Expand All @@ -110,14 +131,16 @@ document.getElementById("table").innerHTML = CSVx.Convert.table(data,{separator:
### Options

```javascript
interface Data { [key: string]: number|string }[]

interface Options {
data?: string; // default : 'text/csv'
charset?: string; // default : 'utf-8'
labels?: boolean; // default : true
quote?: string; // default : '"'
separator?: string; // default : ','
CRLF?: string; // default : '\r\n'
customLabels?: string[]; // default : []
customLabels: { [key: string]: string }; // default : {}
}

interface CSS {
Expand All @@ -126,18 +149,6 @@ interface CSS {
}
```

## Demo

See a basic example **[here](http://csvxjs.lcluber.com/#example)**.

## API Reference

Read the documentation **[here](http://csvxjs.lcluber.com/doc/)**.

## Tests

No tests to run yet

## Contributors

CSVx.js is still in early development and I would be glad to get all the help you can provide for this project.
Expand Down
Loading

0 comments on commit 06d6a3b

Please sign in to comment.