@little-big-apps/xlsx-lib

A full featured and multi-format (xls,xlsx,csv,txt,ods, you name it) spreadsheet validator.

$29

4 downloads
jpicon

spreadsheet-validator

A full featured and multi-format (xls,xlsx,csv,txt,ods, you name it) spreadsheet validator.

In almost any project you have to deal with spreadsheets files in multiple formats (CSV, XLSX, ODS, ETC).

In order to process the information and import it to your DB, it’s always necesary to do validations. The information you have to process needs to fill minimun requeriments in order to prevent DB insert/update failures (datatype, non null data, foreing key validations) and complex business validations.

We created a very small but powerful library that helps you do just that, achiving these goals:

  1. SAVE MONEY: The validation it’s done on the server side, saving processing power on the server and sending unnecesary requests.
  2. SAVE TIME. Each structure you want to define should’t take you more than 5 minutes to configure on a small definition and a maximun of 45 minutes on a really big file (50 columns)
  3. EASY EXTENSIONS. It supports custom functions that can validate with any rule, wile at the same time can normalize the data ( remove unwanted but expected symbols, lowercase, etc)

Installing the library

a) Using npm via terminal

$ npm login --registry https://r.privjs.com
$ npm i -S @little-big-apps/xlsx-lib --registry https://r.privjs.com

b) Using CI/CD environments such as Netlify, Zeit, Travis CI, etc.

  • Add .npmrc file to your project root with the following line: //r.privjs.com/:_authToken=${NPM_TOKEN}
  • Set environment variable NPM_TOKEN with your PrivJs Token in your preferred CI/CD environment

How to use the library

  1. Simply add the XlsxLibModule to your main app module as follows:

Example:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AppComponent } from './app.component';
import { FormsModule } from '@angular/forms';
import { XlsxLibModule } from '@little-big-apps/xlsx-lib';

@NgModule({
  declarations: [
    AppComponent
    
  ],
  imports: [
    BrowserModule,
    XlsxLibModule,
    CommonModule,
    FormsModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. Add the library's Validator service to the constructor of the class you want to use the library in:
constructor(public xlsxLibService: XlsxLibService) {

}
  1. Execute the loadAndValidate function to validate an input file according to the provided settings:
this.xlsxLibService.loadAndValidate(this.file, xlsxSettings).subscribe(result => {
      console.log(result);
});

Demo and Examples

Please refer to the demo project here: https://github.com/robherman/spreadsheet-validator-demo.

Example settings can be found in the project's homepage: https://www.import-javascript-angular-xlsx-csv-validator.com/validations/.

Monetize your
open-source work

Supercharge your OSS projects by selling npm packages. Get started in just 5 minutes.