🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

fastexcel

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastexcel

Fast and efficient large excel file writer

0.2.1
latest
Source
npm
Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

FastExcel

This project need Rust to be installed, check here for Rust installation instruction

This project using Rust and Neon as a binding to Rust to execute fast and efficient memory usage for generating XLSX document from NodeJs.

This project cannot be executed via NVM based NodeJs, you should deactivate (via nvm deactivate) or use a system version installation of NodeJs (via nvm use system).

Writing a large amount of data into Excel file is not a trivial task when you have a limited memory (RAM) allocated. Especially when working at a small node on the server. This library is created to solve that problem, using the efficiency of Rust while generating a large datasheet of XLSX from CSV.

Installation

npm i -D cargo-cp-artifact

npm i fastexcel

How it works

  • Generate the CSV
  • Convert the CSV to XLSX

The CSV generation is happen on the NodeJs side, and converting XLSX file is on Rust side (via Neon)

Example Usage

// dummy-excel.js
const path = require('path');
const { CsvFileWriter, Converter } = require("fastexcel");

const main = async () => {
  const src = path.join(process.cwd(), 'example/source.csv');
  const dst = path.join(process.cwd(), 'example/generated.xlsx');

  const cols = [];
  const totalCols = 200; // 200 columns
  for (let i = 0; i < totalCols; i++) {
    cols.push('Col ' + (i+1));
  }

  const writer = new CsvFileWriter(src, cols);

  const totalRows = 3_00_000; // 300k rows
  for (let i = 0; i < totalRows; i++) {
    let row = [];
    
    for (let i = 0; i < totalCols; i++) {
      row.push('Col No ' + (i+1));
    }

    await writer.write(row);
  }

  await writer.close();

  // Part 2: Convert csv to excel
  const res = await Converter.toXLSX(
    src,
    dst
  );
};

main();

Keywords

excel

FAQs

Package last updated on 15 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts