All Projects → dwqs → Js2excel

dwqs / Js2excel

Licence: mit
😌 😃 👿 A simple module for excel and json converts each other, which works in the browser.

Programming Languages

typescript
32286 projects
js
455 projects

Projects that are alternatives of or similar to Js2excel

Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+34212.05%)
Mutual labels:  excel, json, xlsx
Filecontextcore
FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files instead of being limited to databases.
Stars: ✭ 91 (+9.64%)
Mutual labels:  excel, json, xlsx
Dbwebapi
(Migrated from CodePlex) DbWebApi is a .Net library that implement an entirely generic Web API (RESTful) for HTTP clients to call database (Oracle & SQL Server) stored procedures or functions in a managed way out-of-the-box without any configuration or coding.
Stars: ✭ 84 (+1.2%)
Mutual labels:  excel, json, xlsx
Xresloader
跨平台Excel导表工具(Excel=>protobuf/msgpack/lua/javascript/json/xml)
Stars: ✭ 161 (+93.98%)
Mutual labels:  excel, json, xlsx
Tabtoy
高性能表格数据导出器
Stars: ✭ 1,302 (+1468.67%)
Mutual labels:  excel, json, xlsx
Sq
swiss-army knife for data
Stars: ✭ 275 (+231.33%)
Mutual labels:  excel, json, xlsx
Rows
A common, beautiful interface to tabular data, no matter the format
Stars: ✭ 739 (+790.36%)
Mutual labels:  excel, xlsx
Tableexport
The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
Stars: ✭ 781 (+840.96%)
Mutual labels:  excel, xlsx
Xlnt
📊 Cross-platform user-friendly xlsx library for C++11+
Stars: ✭ 876 (+955.42%)
Mutual labels:  excel, xlsx
Openvasreporting
OpenVAS Reporting: Convert OpenVAS XML report files to reports
Stars: ✭ 42 (-49.4%)
Mutual labels:  excel, xlsx
Readxl
Read excel files (.xls and .xlsx) into R 🖇
Stars: ✭ 585 (+604.82%)
Mutual labels:  excel, xlsx
Luckysheet
Luckysheet is an online spreadsheet like excel that is powerful, simple to configure, and completely open source.
Stars: ✭ 9,772 (+11673.49%)
Mutual labels:  excel, xlsx
Excel2json
把Excel表转换成json对象,并保存到一个文本文件中。
Stars: ✭ 1,023 (+1132.53%)
Mutual labels:  excel, json
Xlsx Populate
Excel XLSX parser/generator written in JavaScript with Node.js and browser support, jQuery/d3-style method chaining, encryption, and a focus on keeping existing workbook features and styles in tact.
Stars: ✭ 668 (+704.82%)
Mutual labels:  excel, xlsx
Pyexcel
Single API for reading, manipulating and writing data in csv, ods, xls, xlsx and xlsm files
Stars: ✭ 902 (+986.75%)
Mutual labels:  excel, xlsx
Sqlitebiter
A CLI tool to convert CSV / Excel / HTML / JSON / Jupyter Notebook / LDJSON / LTSV / Markdown / SQLite / SSV / TSV / Google-Sheets to a SQLite database file.
Stars: ✭ 601 (+624.1%)
Mutual labels:  excel, json
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+1114.46%)
Mutual labels:  excel, xlsx
Excelize
Golang library for reading and writing Microsoft Excel™ (XLSX) files.
Stars: ✭ 10,286 (+12292.77%)
Mutual labels:  excel, xlsx
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (-26.51%)
Mutual labels:  excel, xlsx
Magento2 Import Export Sample Files
Default Magento 2 CE import / export CSV files & sample files for Firebear Improved Import / Export extension
Stars: ✭ 68 (-18.07%)
Mutual labels:  excel, json

download npm-version license bower-license

js2excel

A simple module for excel and json converts each other.

Installation

It is recommended to run webpack on node 6.x or higher.

Install the pkg with npm:

npm install js2excel --save

or yarn

yarn add js2excel

or bower

bower install js2excel

Usage

Convert json to excel

// es6
import {json2excel, excel2json} from 'js2excel';

//CommonJS
let { json2excel, excel2json } = require('js2excel');

// excel's data will be exports, which you probably get it from server.
let data = [
    {
        "userId": 1,
        "userPhoneNumber": 1888888888,
        "userAddress": 'xxxx',
        "date": '2013/09/10 09:10'  // string
    },
    {
        "userId": 2,
        "userPhoneNumber": 1888888888,
        "userAddress": 'xxxx',
        "date": new Date()
    },
    {
        "userId": 3,
        "userPhoneNumber": 1888888888,
        "userAddress": 'xxxx',
        "date": new Date()
    }
];

// this will be export a excel and the file's name is user-info-data.xlsx
// the default file's name is excel.xlsx
try {
    json2excel({
        data,
        name: 'user-info-data',
        formateDate: 'yyyy/mm/dd'
    });
} catch (e) {
    console.error('export error');
}

// for webpack 3: dynamic import
import(/* webpackChunkName: "js2excel" */ 'js2excel').then(({json2excel}) => {
    json2excel({
        data,
        name: 'test',
        formateDate: 'dd/mm/yyyy'
    });
}).catch((e) => {

});

Exports result as the image shows:

test-data

Convert excel(.numbers/.xlsx/.xls) to json

import { excel2json } from 'js2excel';

// html
<input type="file" multiple="false" id="sheets" accept="application/x-iwork-keynote-sffnumbers,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @change="onchange" />

// methods
onchange(e){
    excel2json(e.target.files, (data) => {
        console.log('json', data)
    }, 'excel2json')
}

// for webpack 3: dynamic import
onchange(e) {
    import(/* webpackChunkName: "js2excel" */ 'js2excel').then(({excel2json}) => {
        excel2json(e.target.files, (data) => {
            console.log('json', data)
        }, 'excel2json')
    }).catch((e) => {

    });
}

Example, if you hava a excel as following:

excel

The data maybe as following:

data

API

json2excel(opts)

Convert json to excel(.xlsx).

opts Type: Object

opts.data

Type: Array
Default: []

Excel's data.

opts.name

Type: String
Default: excel

Excel's name, whose suffix is .xlsx.

opts.formateDate

Type: String
Default: dd/mm/yyyy

The date formate in rows' data. Examples:

'dd/mm/yyyy' => 08/07/2017
'd/m/yy' => 8/7/17
'd/m/yy hh:ss' => 8/7/17 18:29
'yyyy/mm/dd hh:ss' => 2017/07/17 18:29

excel2json(files, cb(data), [defval])

Convert excel(.numbers/.xlsx/.xls) to json.

files

Type: Array

FileList from <input type='file' multiple="false" >.

cb(data)

Type: Function

Callback function called on finish. The data maybe as following:

{   
    `${sheetName}`: `[${excelRowsData}]`
    'sheet1': [/** excel rows' data **/],
    'sheet2': [/** excel rows' data **/],
    'sheet3': [/** excel rows' data **/]
    ...
}

defval

Type: String
Default: ''

The default value when the row data corresponding to the column is blank.

csv2json(files, cb(data), [encode])

Convert CSV file to json.

files

Type: Array

FileList from <input type='file' multiple="false" >.

cb(data)

Type: Function

Callback function called on finish.

encode

Type: String
Default: UTF-8

The default encode when reading file.

Supported browsers

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].