html export to excel,GitHub - jmaister/excellentexport: Javascript export to Excel

68747470733a2f2f7472617669732d63692e636f6d2f6a6d6169737465722f657863656c6c656e746578706f72742e7376673f6272616e63683d6d6173746572

68747470733a2f2f646174612e6a7364656c6976722e636f6d2f76312f7061636b6167652f6e706d2f657863656c6c656e746578706f72742f6261646765

68747470733a2f2f6261646765732e6f70656e626173652e696f2f6a732f726174696e672f657863656c6c656e746578706f72742e737667

68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6a6d6169737465722f657863656c6c656e746578706f72742f62616467652e7376673f6272616e63683d6d6173746572

ExcellentExport.js

JavaScript export to Excel or CSV.

A quick JavaScript library to create export to Excel/CSV from HTML tables in the browser. No server required.

As part of the new version 3.0.0+, there is support for XLSX. The drawback is that the library is 600+ KB.

If you only need XLS or CSV, use 2.X.X versions.

Revision history:

3.6.0

Transform the project from JavaScript to TypeScript

Configure Jest as test runner

Update npm dependencies to fix vulnerabilities

3.5.0

Add fixValue and fixArray functions to configuration: these configuration functions can be used to manipulate the values of the cells.

Update npm dependencies to fix vulnerabilities

3.4.3

Update npm dependencies to fix vulnerabilities

3.4.2

Remove ES6 function syntax to support IE11

Update npm dependencies to fix vulnerabilities

3.4.0

Configure TravisCI on GitHub

Update npm dependencies to fix vulnerabilities

3.3.0

Remove columns by index

Filter rows by value

Updated build to Webpack 4.x.x

3.2.1

Update npm dependencies to fix vulnerabilities

3.2.0

Update npm dependencies to fix vulnerabilities

3.1.0

Fix old API for base64 and escaping problem.

3.0.0

XLSX support. This bumps the build size to 640 KB.

New API : ExcellentExport.convert(...)

Autogenerate download filename.

Data input from arrays or HTML Tables.

Multiple sheets for XLS or XLSX formats.

2.1.0

Add Webpack build.

Create UMD JavaScript module. Library can be loaded as a module (import, RequireJS, AMD, etc...) or standalone as window.ExcelentExport.

2.0.3

Fix export as a module.

Changed minifier to UglifyJS.

2.0.2

Fix CSV Chinese characters and other special characters display error in Windows Excel.

Fix URL.createObjectURL(...) on Firefox.

2.0.0

Now it can export to big files +2MB.

Minimum IE 11.

Links open with URL.createObjectURL(...).

NPM package available.

Using Semantic versioning (2.0.0 instead of 2.0).

Module can be loaded standalone or with RequireJS.

Change license to MIT.

1.5

Possibility to select a CSV delimiter.

Bower package available.

Compose package available.

1.4

Add LICENSE.txt with GPL v3

UTF-8 characters fixed.

1.3

Added minified version

1.1

Added CSV data export

1.0

Added Excel data export

Compatibility

Firefox

Chrome

Internet Explorer 11+

Install

npm

npm install excellentexport --save

yarn

yarn add excellentexport

bower

bower install excellentexport

Load

Include script in your HTML:

Include script in your HTML using CDN:

Require.js

require(['dist/excellentexport'], function(ee) {

window.ExcellentExport = ee;

});

ES6 import

import ExcellentExport from 'excellentexport';

Usage

100200300
400500600

Export to Excel

Export to CSV

Export to CSV

API

ExcellentExport.convert(options, sheets);

Options:

{

anchor: String or HTML Element,

format: 'xlsx' or 'xls' or 'csv',

filename: String

}

Sheets must be an array of sheet configuration objects. Sheet description:

[

{

name: 'Sheet 1', // Sheet name

from: {

table: String/Element, // Table ID or table element

array: [...] // Array with the data. Array where each element is a row. Every row is an array of the cells.

},

removeColumns: [...], // Array of column indexes (from 0)

filterRowFn: function(row) {return true}, // Function to decide which rows are returned

fixValue: function(value, row, column) {return fixedValue} // Function to fix values, receiving value, row num, column num

fixArray: function(array) {return array} // Function to manipulate the whole data array

...

},

{

...

}, ...

]

fixValue example

This is an example for the fixValue function to handle HTML tags inside a table cell.

It transforms BR to line breaks and then strips all the HTML tags.

fixValue: (value, row, col) => {

let v = value.replace(/
/gi, "\n");

let strippedString = v.replace(/(]+)>)/gi, "");

return strippedString;

}

Notes

IE8 or lower do not support data: url schema.

IE9 does not support data: url schema on links.

IE10 and above and Edge are supported via the Microsoft-specific msOpenOrSaveBlob method.

Test

python 2.x:

python -m SimpleHTTPServer 8000

python 3.x:

python -m http.server 8000

Build

Install dependencies:

npm install

Build development version dist/excellentexport.js

npm run build

Build publish version of dist/excellentexport.js

npm run prod

Publish

npm publish

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值