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

generate-excel-from-html-table

v1.0.1

Published

This npm package provides a simple and efficient way to generate Excel spreadsheets directly from HTML tables in your React, Angular, or JavaScript applications. With just a few lines of code, you can transform tabular data displayed on your web page into

Downloads

3

Readme

Excel Generator from Template

Coverage Status npm version License

This Excel Generator from HTML module allows you to generate Excel files from an HTML template. It's a lightweight and efficient solution for creating Excel files with customized content. This README provides a step-by-step guide on how to set up and use this module.

Installation

Install ui-modal-and-timeout with npm

  npm i generate-excel-from-html-table --save-dev

How to use

To generate an Excel file from a template, follow these steps:

  1. Open the generateExcelFromTemplate.js file in the project directory.

  2. Modify the context object with your specific parameters. For example:

    const context = {
      worksheet: 'My Sheet',
      table: '<table><tr><td>Data</td></tr></table>',
      id: 'buttonId',
      className: 'buttonClass',
      buttonText: 'Export',
      filename: 'myExcelFile'
    };
    • worksheet: The name of the worksheet in the Excel file.
    • table: HTML table content to include in the Excel file.
    • id, className, buttonText: Button details for the export feature.
    • filename: Desired filename for the Excel file.
  3. Run the script using the following command:

    node generateExcelFromTemplate.js
  4. The generated Excel file will be saved in the same directory with the filename you provided, e.g., myExcelFile.xls.

Example

Here's an example of how to generate an Excel file using this module:

const generateExcelFromTemplate = require('./generateExcelFromTemplate');

const context = {
  worksheet: 'Sales Data',
  table: '<table><tr><td>Product</td><td>Revenue</td></tr><tr><td>A</td><td>$100</td></tr></table>',
  id: 'exportButton',
  className: 'downloadButton',
  buttonText: 'Download Excel',
  filename: 'sales_data'
};

generateExcelFromTemplate(context);

Use in React

  • Import the generateExcelFromTemplate function you've created for generating Excel files using your provided context.
  • Define the Excel Generation Handler.
function App() {
  const handleGenerateExcel = () => {
    const context = {worksheet: 'My Sheet',table: document.getElementById('myTableId'),filename: 'table_data'}
    generateExcelFromTemplate(context);
   }

  return (
    <div className="App">
      <table id="myTableId">
        {/* ... Table content ... */}
      </table>
      <button onClick={handleGenerateExcel}>Generate Excel</button>
    </div>
  );
}

export default App;

Notes

  • This module does not rely on third-party libraries like jsdom, making it lightweight and efficient.
  • Generated Excel files will be saved in the same directory where the script is executed.

License

This project is licensed under the MIT License. Feel free to use and modify it for your needs.

Author

Rahul Jain