GithubHelp home page GithubHelp logo

ghiscoding / excel-builder-vanilla Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 2.0 1.14 MB

Build Excel files from JavaScript

Home Page: https://ghiscoding.github.io/excel-builder-vanilla/

License: MIT License

HTML 16.93% TypeScript 80.53% SCSS 2.44% JavaScript 0.10%
excel excel-export excelwriter spreadsheet

excel-builder-vanilla's Introduction

Excel-Builder-Vanilla

License: MIT TypeScript Vitest codecov Actions Status

NPM downloads npm npm bundle size

Documentation

๐Ÿ“˜ Documentation website powered by GitBook (previous project docs were pulled from web archive)

Description

This lib allows you to build and write an Excel file dynamically, it does not include any reader capabilities making the library super lightweight.

Live Demo

Visit the Live demo to get started and see all available options and methods that the library offers.
You can also take a look at the "Used by" section below to see real world applications taking advantage of this library.

Changelog

CHANGELOG

LICENSE

MIT License

Project History

Excel-Builder-Vanilla is a fork of the popular excel-builder.js project (thanks to @stephenliberty for this great library). The main goal in creating this fork was to modernize the project by removing dependencies that are no longer necessary and replace JSZip by fflate which provides an ESM build giving us Tree Shaking. The other goal was also to provide an ESM bundle to slowly get away from CommonJS (CJS bundle is still offered but we strongly suggest you migrate to the ESM approach)

The modernization steps:

  • migrate to TypeScript (giving us TS Types d.ts)
  • drop Q dependency (we simply use native Promise)
  • drop Lodash dependency (we now use native JS code)
  • replace JSZip dependency with fflate which has an ESM build and offers better performance.
  • bump version to v3.0.0 as a major release (the original project version was in the 2.x range.)
    • note that the changelog did not exists prior to v3.0.0

The project now requires only 1 dependency which is fflate.

Summary

This modernization is providing a huge decrease in the final build size, with now only 1 dependency, and is offering better performance ๐Ÿš€

Installation

Open in Codeflow

npm install excel-builder-vanilla

The project offers 3 different bundle types, choose the best one depending on your use case

  1. ESM: to import from (preferred)
  2. CJS: CommonJS to support old NodeJS require() - will probably be removed in the future
  3. IIFE: standalone script with ExcelBuilder available on the window object
// ESM (preferred) - npm install
import { createWorksheet } from 'excel-builder-vanilla';

// CJS - npm install
const { createWorksheet } = require('excel-builder-vanilla');

// IIFE - CDN
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/excel-builder.iife.js"></script>
<script>
  const worksheet = ExcelBuilder.createWorksheet(); // or window.ExcelBuilder.createWorksheet();
</script>

CSP (Content Security Policy)

Please note that since we use fflate (which creates and compresses the Excel file before sending it to the browser), you might get some CSP errors because of its use of Web Workers. For that reason, you might need to adjust your CSP rules by adding worker-src 'self' blob:;

<meta http-equiv="Content-Security-Policy"
  content="default-src 'self';
   // other rules...
  worker-src 'self' blob:;" />

Used by

This fork was created mostly to support Tree Shaking (ESM), get away from CJS, provide TS Types and update all project dependencies. It is used by a few other Open Source libraries that I also maintain and requires Excel export:

Contributions

PR

Pull Request are welcome, feel free to contribute.

Development / Contributions

If you wish to contribute to the project, please follow these steps:

Note: this project uses pnpm workspaces, you can install pnpm by following their installation or use NodeJS corepack enable to run any of the pnpm scripts shown below:

  1. clone the lib:
    • git clone https://github.com/ghiscoding/excel-builder-vanilla
  2. install it with pnpm from the project root:
    • pnpm install OR npx pnpm install
  3. run a full TypeScript build
    • pnpm run build OR npx pnpm run build
  4. run in development mode (lib & demo)
    • pnpm run dev OR npx pnpm run dev

Pull Request Contribution

Before submitting a PR (pull request), please make sure that you followed these steps for a better chance of a successfull PR:

  1. make sure that you have already executed pnpm install
  2. run the Biome lint npm script (or simply use step 4)
    • pnpm run biome:lint:write
  3. run the Biome code formatting npm script (or simply use step 4)
    • pnpm run biome:format:write
  4. run a full Build (this will also run Biome lint/format, so you could skip step 2)
    • pnpm run build

Sponsors

excel-builder-vanilla's People

Contributors

ghiscoding avatar renovate-bot avatar

Stargazers

Think avatar Truong Le avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.