Coder Social home page Coder Social logo

xiahao90 / js-excel-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ecscstatsconsulting/js-excel-generator

0.0 1.0 0.0 288 KB

JavaScript Library for creating Excel Spreadsheets from HTML Tables

License: MIT License

HTML 71.64% JavaScript 28.36%

js-excel-generator's Introduction

js-excel-generator

A JavaScript Library for creating Excel Spreadsheets from HTML Tables

Overview

A Small HTML JavaScript Library which can be used to create Excel Spreadsheets from HTML Tables.

Live Demo

If you are using the Chrome Web Browser, check out our Chrome App that implements this library. You can use this app to see if the js-excel-generator is right for your project. The Chrome App is also an open source project, you can view the source code here

The project is still very early in development, more updates will follow shortly.

Getting Started - How to use

  • Include and reference the excel-gen.js library and the jquery, jszip and FileSaver dependencies

    example:

   <script type="text/javascript" src="./external/jquery-1.8.2.js"></script>
   <script type="text/javascript" src="./external/jszip.js"></script>
   <script type="text/javascript" src="./external/FileSaver.js"></script>
   <script type="text/javascript" src="./scripts/excel-gen.js"></script>
  • Call the library within on the desired HTML Table

    example:

$(document).ready(function () {
   //Creates new Generator
   excel = new ExcelGen({
       "src_id": "[ID For Table]",
       "show_header": true,
       "file_name": "myExcelOutput.xlsx"
   });
   //Generates Excel Output and sends download to the browser.
   excel.generate();
});

Usage - Options

The following options are current available:

{
    "src_id": "",
    "src": null
    "header_row": null,
    "body_rows": null,
    "format": "xlsx|csv",
    "type": "table|normal",
    "show_header": false,
    "author": "JavaScript Excel Generator",
    "file_name": "output.xlsx",
    "column_formats": [],
    "exclude_selector": null
}

src_id - ID of HTML Table to Export to Excel. Can use src or header_row and body_rows instead.

src - jQuery element of the HTML Table to Export to Excel

header_row - JQuery Element of the header TR tag, if src_id or src is not specified this will be used.

body_rows - Jquery Elements of the body TR tags, if src_id or src is not specified this will be used.

note: both header_row and body_rows properties must be set if not using src_id

format - Specifies the output format, current options are xlsx for standard workbook or csv for CSV output.

type - If set to 'table', the output will be generated inside of a Filterable Excel Table

show_header - Show the header on the Excel Output

author - Name to be listed as the author of the Excel Output

file_name - File name of the Excel Output

column_formats - Array of column formats (see demo for more info). For a list of column formats see ExcelDataFormats.md

exclude_selector - jquery selector of cells to exclude from output in to Excel. NOTE: all cells along a column of the table must be excluded, otherwise the output spreadsheet will be broken. See the last example in the demo for more info.

Dependencies

The code uses jQuery, jszip.js and FileSaver.js. For ease of use, these libraries have been included in the 'external' folder of this project.

ecsc

js-excel-generator's People

Contributors

ecscstatsconsulting avatar paul0warren avatar

Watchers

 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.