All Projects → JackGit → Table2excel.js

JackGit / Table2excel.js

Export html table to excel file in browser

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Table2excel.js

Rows
A common, beautiful interface to tabular data, no matter the format
Stars: ✭ 739 (+526.27%)
Mutual labels:  xlsx, xls, table
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+24034.75%)
Mutual labels:  xlsx, xls, table
Npoi.mapper
Use this tool to import or export data with Excel file. The tool is a convention based mapper between strong typed object and Excel data via NPOI.
Stars: ✭ 348 (+194.92%)
Mutual labels:  xlsx, xls
Easyexcel
快速、简单避免OOM的java处理Excel工具
Stars: ✭ 22,133 (+18656.78%)
Mutual labels:  xlsx, xls
Phpspreadsheet
A pure PHP library for reading and writing spreadsheet files
Stars: ✭ 10,627 (+8905.93%)
Mutual labels:  xlsx, xls
Msoffcrypto Tool
Python tool and library for decrypting MS Office files with passwords or other keys
Stars: ✭ 274 (+132.2%)
Mutual labels:  xlsx, xls
J
❌ Multi-format spreadsheet CLI (now merged in http://github.com/sheetjs/js-xlsx )
Stars: ✭ 343 (+190.68%)
Mutual labels:  xlsx, xls
Readxl
Read excel files (.xls and .xlsx) into R 🖇
Stars: ✭ 585 (+395.76%)
Mutual labels:  xlsx, xls
exoffice
Library to parse common excel formats (xls, xlsx, csv)
Stars: ✭ 31 (-73.73%)
Mutual labels:  xlsx, xls
Tableexport
The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
Stars: ✭ 781 (+561.86%)
Mutual labels:  xlsx, xls
Pyexcel
Single API for reading, manipulating and writing data in csv, ods, xls, xlsx and xlsm files
Stars: ✭ 902 (+664.41%)
Mutual labels:  xlsx, xls
grate
A Go native tabular data extraction package. Currently supports .xls, .xlsx, .csv, .tsv formats.
Stars: ✭ 98 (-16.95%)
Mutual labels:  xlsx, xls
dbd
dbd is a database prototyping tool that enables data analysts and engineers to quickly load and transform data in SQL databases.
Stars: ✭ 30 (-74.58%)
Mutual labels:  xlsx, xls
Android Gradle Localization Plugin
Gradle plugin for generating localized string resources
Stars: ✭ 100 (-15.25%)
Mutual labels:  xlsx, xls
workbook
simple framework for containing spreadsheet like data
Stars: ✭ 13 (-88.98%)
Mutual labels:  xlsx, xls
Docjure
Read and write Office documents from Clojure
Stars: ✭ 510 (+332.2%)
Mutual labels:  xlsx, xls
tabular-stream
Detects tabular data (spreadsheets, dsv or json, 20+ different formats) and emits normalized objects.
Stars: ✭ 34 (-71.19%)
Mutual labels:  xlsx, xls
spark-hadoopoffice-ds
A Spark datasource for the HadoopOffice library
Stars: ✭ 36 (-69.49%)
Mutual labels:  xlsx, xls
Documentbuilder
ONLYOFFICE Document Builder is powerful text, spreadsheet, presentation and PDF generating tool
Stars: ✭ 61 (-48.31%)
Mutual labels:  xlsx, xls
Desktopeditors
An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
Stars: ✭ 1,008 (+754.24%)
Mutual labels:  xlsx, xls

Table2Excel.js

This is a library to export html tables to excel sheets.

Precondition

It has to be a row * column table

Features

  1. able to export with width, alignment and colors
  2. extendable

Dependencies

ExcelJS

FileSaver.js

Live Demo

Demo

Include table2excel.js

npm

ExcelJS is peer dependency to table2excel.js, so you need to install exceljs first:

npm i exceljs

then, install table2excel.js:

npm i table2excel.js

use in your code like:

import Table2Excel from 'table2excel.js'
new Table2Excel('table').export()

you may also need a config in webpack:

node: { fs: 'empty' }

table2excel.min.js (with ExcelJS packed)

<script src="path/to/table2excel.min.js"></script>

table2excel.core.js (without ExcelJS packed)

<script src="path/to/exceljs.min.js"></script>
<script src="path/to/table2excel.core.js"></script>

Basic Usage

const table2Excel = new Table2Excel(selector, options)  // new Table2Excel('table')
table2Excel.export(fileName, extension) // table2Excel.export('my-exported-table', 'xlsx')

extension can be 'xls' or 'xlsx', default as 'xlsx'

selector

It's optional, and defaulted as 'table'

options

It's optional, and defaulted as:

{
  workbook: {
    views: [{
      x: 0, y: 0, width: 10000, height: 20000,
      firstSheet: 0, activeTab: 1, visibility: 'visible'
    }]
  },
  widthRatio: .14,
  plugins: [
    Table2Excel.plugins.fontPlugin,
    Table2Excel.plugins.fillPlugin,
    Table2Excel.plugins.formPlugin,
    Table2Excel.plugins.alignmentPlugin,
    Table2Excel.plugins.hyperlinkPlugin,
    Table2Excel.plugins.autoWidthPlugin
  ]
}

workbook is options used while creating a workbook, please refer exceljs#create-a-workbook for details.

widthRatio is a ratio that will be used while converting width style of html table cells to width of sheet cells.

Plugins

Plugin helps to extend the ability of transforming table to excel.

Build-in plugins can be access like:

Table2Excel.plugins.fontPlugin,
Table2Excel.plugins.fillPlugin,
Table2Excel.plugins.formPlugin,
Table2Excel.plugins.alignmentPlugin,
Table2Excel.plugins.hyperlinkPlugin,
Table2Excel.plugins.autoWidthPlugin

A plugin can be defined to join different phase of table to excel process, and in different phase, plugin is able to access different objects from context.

{
  /**
   * after an empty workbook created
   * @param  {ExcelJS.Workbook} context.workbook
   * @param  {NodeList} context.tables   
   */
  workbookCreated ({ workbook, tables }) {},
  /**
   * after an empty worksheet created
   * @param  {ExcelJS.Workbook} workbook
   * @param  {NodeList} tables
   * @param  {ExcelJS.Worksheet} worksheet
   * @param  {HTMLTableElement} table
   */
  worksheetCreated ({ workbook, tables, worksheet, table }) {},
  /**
   * after a worksheet been filled with data from table
   * @param  {ExcelJS.Workbook} workbook
   * @param  {NodeList} tables
   * @param  {ExcelJS.Worksheet} worksheet
   * @param  {HTMLTableElement} table
   */
  worksheetCompleted ({ workbook, tables, worksheet, table }) {},
  /**
   * after an cell of worksheet created
   * @param  {ExcelJS.Workbook} workbook
   * @param  {NodeList} tables
   * @param  {ExcelJS.Worksheet} worksheet
   * @param  {HTMLTableElement} table
   * @param  {ExcelJS.Cell} workcell
   * @param  {HTMLTableCellElement} cell
   * @param  {colRange} [from, to]
   * @param  {rowRange} [from, to]
   */
  workcellCreated ({ workbook, tables, worksheet, table, workcell, cell, cellStyle, colRange, rowRange }) {}
}

Example 1, you can define a plugin to make some rows or columns hidden of exported excel:

const table2Excel = new Table2Excel('table', {
  plugins: [{
    worksheetCompleted ({ workbook, tables, worksheet, table }) {
      worksheet.getRow(1).hidden = true
      worksheet.getColumn(1).hidden = true
    }
  }]
})

Example 2, you can add your customized cell parser for your table:

const table2Excel = new Table2Excel('table', {
  plugins: [{
    workcellCreated ({ workbook, tables, worksheet, table, workcell, cell, cellStyle, rowRange, colRange }) {
      workcell.value = { text: '', link: '' }
      workcell.style = {
        ...workcell.style,
        font: {},
        color: {}
      }
    }
  }]
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].