react-data-export
Advanced tools
Comparing version 0.3.1 to 0.3.2
{ | ||
"name": "react-data-export", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "description": "A set of tools to export dataset from react to different formats.", |
@@ -45,2 +45,15 @@ # React-Data-Export | ||
var dataSet2 = [ | ||
{ | ||
name: "Johnson", | ||
total: 25, | ||
remainig: 16 | ||
}, | ||
{ | ||
name: "Josef", | ||
total: 25, | ||
remainig: 7 | ||
} | ||
]; | ||
class App extends React.Component { | ||
@@ -57,2 +70,7 @@ render() { | ||
</ExcelSheet> | ||
<ExcelSheet data={dataSet2} name="Leaves"> | ||
<ExcelColumn label="Name" value="name" /> | ||
<ExcelColumn label="Total Leaves" value="total" /> | ||
<ExcelColumn label="Remaining Leaves" value="remaining" /> | ||
</ExcelSheet> | ||
</ExcelFile> | ||
@@ -66,4 +84,57 @@ ); | ||
With release `0.3.0` and upwards you can also pass **multiple** dataset to *ExcelSheet*, and you can have more than one *ExcelSheets* in 1 excel file. | ||
```javascript | ||
/*When you want to use dataSet directly, you can specify multiple data to single ExcelSheet with following structure, | ||
//i.e You can have multiple dataSets on Multiple Sheets in Single Excel File | ||
interface { | ||
xSteps?: number; //How many cells to skips from left (Optional) | ||
ySteps?: number; //How many rows to skips from last data (Optional) | ||
columns: [array | string] //array (required) | ||
data: [array_of_array | string|boolean|number] //array of arrays (required) | ||
} | ||
*/ | ||
import React from "react" | ||
import {default as ExcelFile, ExcelSheet} from "react-data-export" | ||
const multiDataSet = [ | ||
{ | ||
columns: ["Name", "Salary", "Sex"], | ||
data: [ | ||
["Johnson", 30000, "Male"], | ||
["Monika", 355000, "Female"], | ||
["Konstantina", 20000, "Female"], | ||
["John", 250000, "Male"], | ||
["Josef", 450500, "Male"], | ||
] | ||
}, | ||
{ | ||
xSteps: 1, // Will start putting cell with 1 empty cell on left most | ||
ySteps: 5, //will put space of 5 rows, | ||
columns: ["Name", "Department"], | ||
data: [ | ||
["Johnson", "Finance"], | ||
["Monika", "IT"], | ||
["Konstantina", "IT Billing"], | ||
["John", "HR"], | ||
["Josef", "Testing"], | ||
] | ||
} | ||
]; | ||
class App extends React.Component { | ||
render() { | ||
return ( | ||
<ExcelFile> | ||
<ExcelSheet dataSet={multiDataSet} name="Organization" /> | ||
<!-- You can add more ExcelSheets if you need --> | ||
</ExcelFile> | ||
); | ||
} | ||
} | ||
``` | ||
## Dependencis | ||
This package uses [file-saver](https://www.npmjs.com/package/file-saver) and [xlsx](https://www.npmjs.com/package/xlsx) and using [json-loader](https://www.npmjs.com/package/json-loader) will do the magic for you. | ||
This library uses [file-saver](https://www.npmjs.com/package/file-saver) and [xlsx](https://www.npmjs.com/package/xlsx) and using [json-loader](https://www.npmjs.com/package/json-loader) will do the magic for you. | ||
@@ -70,0 +141,0 @@ |
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
31694
15
154
1