Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/victorboissiere/vue-xls-csv-parser

Simple VueJS component to parse XLS/CSV files with validation
https://github.com/victorboissiere/vue-xls-csv-parser

csv parser vuejs xlsx

Last synced: about 2 months ago
JSON representation

Simple VueJS component to parse XLS/CSV files with validation

Awesome Lists containing this project

README

        

# Vue XLS/CSV parser

## Description

This npm package will help you parse XLS/CSV files and validate them. The user will be asked to associate his file columns with the columns you require. Once validated, an event will be triggered where you will be able to get only the data you need.

![Demo](wiki/demo.gif)

## Requirements

You will need Bootstrap 3.x. It has not been tested yet with Boostrap 4.

## Components

### XlsCsvParser

#### Props

| Name | Type | Description |
| ------------ |:-------------:| -----:|
| columns (required) | Array | An array of object representing the columns you required: `[{ name: 'Student login', value: 'login', isOptional: false }]` |
| validateButtonId | String | The id of the custom validate button. The component validation button will not be displayed |
| help | String | Help text shown on the file dropzone |
| lang | String | `en`, `nl` or `fr`. Default: `en` |

#### Events

- `onValidate(results)`: all the data parsed by the component and returned after the user validation

#### Example usage

```html


Example - Import file with required login, firstname, lastname and optional values









Results:


{{ JSON.stringify(results, null, 2) }}


import { XlsCsvParser } from 'vue-xls-csv-parser';
export default {
name: 'App',
components: {
XlsCsvParser,
},
methods: {
onValidate(results) {
this.results = results;
},
},
data() {
return {
columns: [
{ name: 'Student login', value: 'login' },
{ name: 'Student firstname', value: 'firstname' },
{ name: 'Student lastname', value: 'lastname' },
{ name: 'Other', value: 'other', isOptional: true },
],
results: null,
help: 'Necessary columns are: login, firstname and lastname',
};
},
};

```

## Tests

Simpliy run `yarn mocha`.

## Build Setup

``` bash
# install dependencies
yarn intall

# serve with hot reload at localhost:8080
yarn start

# build for a release
yarn bundle:dist
```