Introduction

Let users load a sheet and map its columns to your model.

Installation

The package is published as react-sheets-import on npm and thus can be installed through:

# For yarn users:
yarn add react-sheets-import

# For npm users:
npm install react-sheets-import

Basic Example

import { Types, mapColumnsToRows } from 'react-sheets-import';

const User = Types.Object({
    name: Types.String(),
    email: Types.String()
});
const rows = [
    ['John', 'john@gmail.com'],
    ['Jane', 'jane@gmail.com']
];
const users = mapColumnsToRows(User, rows);

In the above example, users evaluates to:

[
    {
        "name": "John",
        "email": "john@gmail.com"
    },
    {
        "name": "Jane",
        "email": "jane@gmail.com"
    }
]

Last updated