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

xlsx-downloader

v1.0.3

Published

A wrapper for ExcelJS to simplify Excel file generation

Downloads

272

Readme

📊 Excel Downloader: ExcelJS Wrapper for Spreadsheet Sorcery! 🧙‍♂️

Excel Downloader is a magical wrapper around the powerful ExcelJS library, designed to simplify your spreadsheet creation process. Turn data into Excel files with a flick of your wand!

🚀 Installation

Summon this package to your project with:

npm install xlsx-downloader

🎭 Usage: Excel-erate Your Workflow!

Here's how to conjure your first magical spreadsheet:

import { ExcelGenerator } from "xlsx-downloader";

// Prepare your data
const sheetsData = [
  {
    headers: ["Wizard Name", "Spells Known", "Favorite Potion"],
    data: [
      ["Gandalf", 1000, "Earl Grey Tea"],
      ["Harry Potter", 31, "Butterbeer"],
      ["Dr. Strange", 678, "Green Smoothie"],
    ],
    header_format: { font: { bold: true, color: { argb: "FF7F50FF" } } },
    sheet_name: "Wizarding World",
  },
];

// Create the Excel file
const excelGenerator = new ExcelGenerator(sheetsData);

excelGenerator.generate().then((buffer) => {
  // In a Node.js environment, save the file
  require("fs").writeFileSync("wizard_data.xlsx", buffer);
  console.log("🎉 Wizard data successfully catalogued!");
  // In a browser environment, trigger a download
  // const blob = new Blob([buffer], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
  // const url = window.URL.createObjectURL(blob);
  // const a = document.createElement('a');
  // a.href = url;
  // a.download = 'wizard_data.xlsx';
  // a.click();
});

🧙‍♀️ Casting More Complex Spells

Need multiple sheets or fancy formatting? No problem!

const advancedSheetsData = [
  {
    headers: ["Potion", "Ingredients", "Brewing Time (hours)"],
    data: [
      ["Love Potion", "Rose petals, Unicorn hair", 72],
      ["Invisibility Elixir", "Moonstone, Ghost essence", 168],
      ["Dragon Breath", "Chili peppers, Dragon scales", 24],
    ],
    header_format: {
      font: { bold: true, color: { argb: "FFFFFFFF" } },
      fill: {
        type: "pattern",
        pattern: "solid",
        fgColor: { argb: "FF800080" },
      },
    },
    sheet_name: "Potions",
  },
  {
    headers: ["Spell", "Difficulty", "Power Level"],
    data: [
      ["Wingardium Leviosa", "Beginner", 3],
      ["Expecto Patronum", "Advanced", 10],
      ["Avada Kedavra", "Unforgivable", 100],
    ],
    header_format: {
      font: { bold: true, italic: true },
      alignment: { horizontal: "center" },
    },
    sheet_name: "Spellbook",
  },
];

const advancedExcel = new ExcelGenerator(advancedSheetsData);

advancedExcel.generate().then((buffer) => {
  // Save or download your multi-sheet, formatted Excel file
});

🎩 Tips and Tricks

  1. Sheet Names: Each sheet must have a unique name. Choose wisely!
  2. Header Formatting: Make your headers stand out with custom styles. Our wrapper simplifies ExcelJS's styling options.
  3. Data Types: Numbers, strings, and dates are all welcome in your data arrays, just like in ExcelJS.
  4. Buffer Handling: The generate() method returns a Promise that resolves to a Buffer, consistent with ExcelJS's output.

🔮 Why Use This Wrapper?

Excel Downloader simplifies the process of creating Excel files with ExcelJS. It provides:

  • A streamlined API for quick Excel file generation
  • Easy multi-sheet creation
  • Simplified header formatting
  • Consistent interface for both Node.js and browser environments

While it doesn't expose all of ExcelJS's features, it covers the most common use cases for generating downloadable Excel files.

📚 ExcelJS Documentation

For more advanced features or direct ExcelJS usage, refer to the official ExcelJS documentation.

📜 License

MIT (Magical Institute of Technology)

Remember, this wrapper brings the magic of ExcelJS to your fingertips with a simpler spell. Use it wisely, and may your data always flow smoothly! 🧙‍♂️✨