This repository has been archived by the owner. It is now read-only.
No description, website, or topics provided.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib Merge pull request #21 from Data-Meister/master Sep 26, 2015
.gitignore
.versions
LICENSE.md Create LICENSE.md Nov 14, 2016
README.md Update README.md Dec 5, 2015
excel-tests.js fix for windows Dec 18, 2015
excel.js fix for windows Dec 18, 2015
package.js
versions.json

README.md

meteor-excel

Mainly this package is a wrap for the npm packages listed below. So checkout their documentation to see how to work with excel files properly.

Parsing and generating excel files (xlsx, xls).

This package uses the npm packages:

Getting Started

There is nothing like a good example to get started with this package. Check out this MeteorPad for an exportable leaderboard to excel file. Follow the comments in the meteorpad, mainly in the server/app.js file.

Three steps to use it (basic cover)

1.- GET YOU APP PATH..

var fs = Npm.require('fs');
var path = Npm.require('path');
var basepath = path.resolve('.').split('.meteor')[0];

2.- CREATE A NEW EXCEL OBJECT

___ This package exports the Excel object to the server. Meaning this package is currently available only to the server side.___

To work with excel files first create an Excel object matching the excel file type you want to handle: xlsx/xls. To do that just use:

var excel = new Excel('xls');

or

var excel = new Excel('xlsx');

3.- READING XLS/X

  • Read a file
var workbook = excel.readFile( basepath+'yourFilesFoler/someExcelFile.xls'); 
  • Get the SheetNames (this is important to use most of the functions)
var yourSheetsName = workbook.SheetNames;
  • Get a cell
console.log("Get the 1st Sheet Name (remember is an array): " + workbook.SheetNames[0]);
console.log("Get Some Cell from it: " + workbook.Sheets[yourSheetsName[0]][
'C37'].v);
  • Make a JSON out of your excel
// We want JSON for this sheet:
var sheet = workbook.Sheets[yourSheetsName[0]]

// You can get the sheet as list of lists.
var options = { header : 1 }

// Or you  can get an object with column headers as keys.  
var options = { header : ['title', 'fName', 'sName' ,'address' ] }

// If options is empty or omitted, it should use the first-row headers by default. 
// However this doesn't seem to work with all Excel worksheets. 
var options = {}

// Generate the JSON like so:
var workbookJson = excel.utils.sheet_to_json( sheet, options );
  • Make a CSV out of your excel
var workbookCsv = excel.utils.sheet_to_csv(workbook.Sheets[yourSheetsName[0]]);
console.log(workbookCsv.length);

Contribute

Used this package? got an example to show? conact me or PR the README and i'll happly add it :)