• Stars
    star
    112
  • Rank 310,449 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convert and download html tables to a xlsx-file that can be opened in Microsoft Excel

table2excel

table2excel is a ecma5 compiled vanilla javascript plugin to convert and download html tables to a xlsx-file that can be opened in Microsoft Excel.

It uses the awesome js-xlsx plugin from Sheet JS as a dependency. Thanks!

Demo

Quick Start

<script src="table2excel.js"></script>

<script>
  var table2excel = new Table2Excel();
  table2excel.export(document.querySelectorAll("table"));
</script>

Node

// npm install table2excel --save
import 'table2excel';
const Table2Excel = window.Table2Excel;

const table2excel = new Table2Excel(options);

See my webpack configuration to see how to get js-xlsx running with webpack in the browser.

Additional options

You can pass in options as a parameter like new Table2Excel(options). The currently supported options are:

  • defaultFileName: The general file name of a downloaded document. Default: 'file'. Can also be adjusted individually for export as a second parameter, e.g. table2excel.export(table, "cool table");.
  • tableNameDataAttribute: Data attribute name to identify the worksheet name of a table. Default: 'excel-name'. Usage: <table data-excel-name="Check this out">...</table>. If not set, worksheets are numbered incrementally from 1.

Cell type handlers

table2excel detects a few special cells by default to display them correctly in Excel:

  • Numbers
  • Inputs: for input[type="text"], select or textarea elements
  • Dates: tries to parse the date or set the exact timestamp via data-timestamp on the cell (recommended!)
  • Booleans: parses 'true', 'false' or checkboxes/radios without text to booleans
  • Lists: parses <ul>...</ul> or <ol>...</ol> list elements to '..., ...'

Everything else will just get displayed as simple text. You can easily though add custom type handlers for your own needs:

Table2Excel.extend((cell, cellText) => {
  // {HTMLTableCellElement} cell - The current cell.
  // {string} cellText - The inner text of the current cell.

  // cell should be described by this type handler
  if (selector) return {
    t: ...,
    v: ...,
  };

  // skip and run next handler
  return null;
});

The return value must be a js-xlsx cell object.

Contributing

If you would like to submit a pull request with any changes you make, please feel free! Simply run npm test to test and npm start to compile before submitting pull requests.

Issues

Please use the GitHub issue tracker to raise any problems or feature requests.

More Repositories

1

pytorch_scatter

PyTorch Extension Library of Optimized Scatter Operations
Python
1,531
star
2

pytorch_sparse

PyTorch Extension Library of Optimized Autograd Sparse Matrix Operations
Python
990
star
3

pytorch_cluster

PyTorch Extension Library of Optimized Graph Cluster Algorithms
C++
798
star
4

deep-graph-matching-consensus

Implementation of "Deep Graph Matching Consensus" in PyTorch
Python
256
star
5

pytorch_spline_conv

Implementation of the Spline-Based Convolution Operator of SplineCNN in PyTorch
C++
169
star
6

pyg_autoscale

Implementation of "GNNAutoScale: Scalable and Expressive Graph Neural Networks via Historical Embeddings" in PyTorch
Python
157
star
7

deep-learning-cheatsheet

TeX
92
star
8

embedded_gcnn

Embedded Graph Convolutional Neural Networks (EGCNN) in TensorFlow
Jupyter Notebook
78
star
9

himp-gnn

Hierarchical Inter-Message Passing for Learning on Molecular Graphs
Python
75
star
10

koa2-rest-api

ES6 RESTFul Koa2 API with Mongoose and OAuth2
JavaScript
75
star
11

graph-based-image-classification

Implementation of Planar Graph Convolutional Networks in TensorFlow
Python
43
star
12

pytorch_unique

PyTorch Extension Library of Optimized Unique Operation
Python
37
star
13

deep-learning-on-graphs

TeX
31
star
14

mongoose-i18n-localize

Mongoose plugin to support i18n and localization
JavaScript
22
star
15

dotfiles

Shell
18
star
16

RSClipperWrapper

A small and simple wrapper for the Clipper library to perform polygon clipping (Swift)
C++
17
star
17

RSShapeNode

A RSShapeNode object draws a shape by rendering a Core Graphics path offscreen using a disconnected CAShapeLayer and snapshots the image to a SKSpriteNode (Swift)
Swift
8
star
18

rusty1s.github.io

HTML
6
star
19

pytorch_bincount

Python
6
star
20

vim-happy-hacking

Vim Script
5
star
21

rusty1s

4
star
22

table-select

Allows you to select table row elements like in your standard finder environment
JavaScript
3
star
23

DigDeeper

the Mining / Crafting / Trading game (Swift 2.0)
C++
3
star
24

react-pattern-library

React Pattern Library for various UI components
JavaScript
3
star
25

mongoose-i18n-error

lightweight module for node.js/express.js to create beautiful mongoose i18n validation error messages
JavaScript
2
star
26

react-dev-config

Customizable Configuration for modern React apps
JavaScript
2
star
27

mongoose-integer

mongoose plugin to validate integer values within a Mongoose Schema
JavaScript
2
star
28

hyper-happy-hacking

JavaScript
1
star
29

RSRoundBorderedButton

Round bordered Button like the ones used in the Apple AppStore (Swift)
Swift
1
star
30

ComputationOffloading

Energieeffizienz durch Computation Offloading in der Cloud
1
star
31

react-documentviewer

React Documentviewer for various mimetypes
JavaScript
1
star
32

RSRandomPolygon

Swift
1
star
33

tensorflow-graph-plugin

Python
1
star
34

dependent-select-boxes

Allows a child select box to change its options dependent on its parent select box
JavaScript
1
star
35

texture-synthesis

TeX
1
star
36

RSScene

An inheritance of SKScene that adds a game logic loop to the runtime of a scene (Swift)
Swift
1
star
37

OCF-andCP-Networks

Qualitative Semantiken fĂŒr DAGs - ein Vergleich von OCF- und CP-Netzwerken
1
star
38

js-dev-utils

JavaScript
1
star
39

RSContactGrid

A triangular/square/rotated square/hexagonal grid tile map with contact detection for any path (Swift 2.0)
Swift
1
star