npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nich-xlsx

v2.0.6

Published

Making XLSX files

Downloads

68

Readme

Based on XLSX npm module.

#Installation

npm i nich-xlsx

#Running the simple index.js file via terminal

  1. Make index.js file.
  2. Copy and paste code from the simple exapmle on the bottom of this page into the new index.js file.
  3. Save file.
  4. Open terminal into the current folder with your index.js file. on Windows [Win+R > write cmd > Enter] on Mac [CMD + Space > write terminal > Enter]
  5. Run npm i nich-xlsx command.
  6. Then run node index.js command.
  7. In your terminal you should see console logs =) I hope they would be successful.
  8. In your current folder should be new 'folderName' folder and in it should be testName.xlsx file with default data.

#Class methods:

 // Set path for file
 // @param {string} filePath [global path to the file]
setFilePath(filePath);
// Set name for file
// @param {string} fileName [file name =)]
setFileName(fileName);
// Set workSheetName for your xlsx file in Excel
// @param {string} workSheetName [sheet name]
setWorkSheetName(workSheetName);
// Set main data in your xlsx file into two-dimensional massive
// @param {array} mainData [main data into two-dimensional array]
setMainData(mainData);
// Set header data into one-dimensional massive
// @param {array} headerData [header one-dimensional array]
setHeaderData(headerData);
// Clear all class data
clearAllData();
// Make new xlsx file
makeFile();

#Index.js Simple Example File

var nichxlsx = require('nich-xlsx');
var path = require('path');

// Additional options for package
// @param {boolean} devMode [enable or disable developer mode,
//   default value - false]
// @param {boolean} disableFinishConsoleLog [on/of console log after writing file
//   default value - false]
// @param {boolean} autoAddExtension [autoAdding '.xlsx' extension
//   default value - false]

var options = {
  // devMode: true,
  // disableFinishConsoleLog: true,
  autoAddExtension: true,
}

// init class for xlsx files
var folder = new nichxlsx.default(options); // passing options to the xlsx class

// init data for file
var filePath = path.join(__dirname, 'folderName'); // add file in folder 'folderName'
var fileName = 'testName'; // fileName without '.xlsx' extension
var workSheetName = 'sheetName'; // name for sheet name in Excel
var mainData = [['d11','d12','d13'],['d21','d22','d23'],['d31','f32','f33']]; // main data
var headerData = ['header 1', 'header 2', 'header 3']; // headers for main data columns

try {
  // passing data for the file
  folder.setFilePath(filePath);
  folder.setFileName(fileName);
  folder.setWorkSheetName(workSheetName);
  folder.setMainData(mainData);
  folder.setHeaderData(headerData);

  // make new xlsx file
  folder.makeFile();

  // clear all data
  folder.clearAllData();

  // passing almost the same data
  folder.setFileName(fileName + 'SecondFile'); // change file name for next file
  folder.setFilePath(filePath);
  folder.setMainData(mainData); // only mainData without headerData

  // make another xlsx file
  folder.makeFile();
} catch (error) {
  console.log('Throw ERROR!' + error.name + ' | ' + error.message);
}

If you have Errors like this: #Error: Cannot resolve module 'fs' so you need to modify your webpack config file:

...
target: 'node',
node: {
	fs: "empty",
	__dirname: false,
}
...

If you have problem with jszip or mkdirp, then you need also add these lines:

...
externals: [
	{
		'./jszip': 'jszip',
		'./cptable': 'var cptable',
		'Mkdirp': 'mkdirp',
		'Xlsx': 'xlsx'
	}
]
...