tableExport.jquery.plugin
=========================
<h3>Export HTML Table to</h3>
<ul>
<li> CSV
<li> DOC
<li> JSON
<li> PDF
<li> PNG
<li> SQL
<li> TSV
<li> TXT
<li> XLS (Excel 2000 HTML format)
<li> XLSX (Excel 2007 Office Open XML format)
<li> XML (Excel 2003 XML Spreadsheet format)
<li> XML (Raw xml)
</ul>
Installation
============
To save the generated export files on client side, include in your html code:
```javascript
<script type="text/javascript" src="libs/FileSaver/FileSaver.min.js"></script>
```
To export the table in XLSX (Excel 2007+ XML Format) format, you need to include additionally:
```javascript
<script type="text/javascript" src="libs/js-xlsx/xlsx.core.min.js"></script>
```
To export the table as a PDF file the following includes are required:
```javascript
<script type="text/javascript" src="libs/jsPDF/jspdf.min.js"></script>
<script type="text/javascript" src="libs/jsPDF-AutoTable/jspdf.plugin.autotable.js"></script>
```
To export the table in PNG format, you need to include:
```javascript
<script type="text/javascript" src="libs/html2canvas/html2canvas.min.js"></script>
```
Regardless of the desired format, finally include:
```javascript
<script type="text/javascript" src="tableExport.min.js"></script>
```
Please keep this include order.
Examples
========
```javascript
// CSV format
$('#tableID').tableExport({type:'csv'});
```
```javascript
// Excel 2000 html format
$('#tableID').tableExport({type:'excel'});
```
```javascript
// XML Spreadsheet 2003 file format with multiple worksheet support
$('table').tableExport({type:'excel',
excelFileFormat:'xmlss',
worksheetName: ['Table 1','Table 2', 'Table 3']});
```
```javascript
// PDF export using jsPDF only
$('#tableID').tableExport({type:'pdf',
jspdf: {orientation: 'p',
margins: {left:20, top:10},
autotable: false}
});
```
```javascript
// PDF format using jsPDF and jsPDF Autotable
$('#tableID').tableExport({type:'pdf',
jspdf: {orientation: 'l',
format: 'a3',
margins: {left:10, right:10, top:20, bottom:20},
autotable: {styles: {fillColor: 'inherit',
textColor: 'inherit'},
tableWidth: 'auto'}
}
});
```
```javascript
// PDF format with callback example
function DoCellData(cell, row, col, data) {}
function DoBeforeAutotable(table, headers, rows, AutotableSettings) {}
$('table').tableExport({fileName: sFileName,
type: 'pdf',
jspdf: {format: 'bestfit',
margins: {left:20, right:10, top:20, bottom:20},
autotable: {styles: {overflow: 'linebreak'},
tableWidth: 'wrap',
tableExport: {onBeforeAutotable: DoBeforeAutotable,
onCellData: DoCellData}}}
});
```
Options (Default settings)
=======
```javascript
consoleLog: false
csvEnclosure: '"'
csvSeparator: ','
csvUseBOM: true
displayTableName: false
escape: false
excelstyles: []
excelFileFormat: 'xlshtml'
fileName: 'tableExport'
htmlContent: false
ignoreColumn: []
ignoreRow: []
jsonScope: 'all'
jspdf: orientation: 'p'
unit:'pt'
format: 'a4'
margins: left: 20
right: 10
top: 10
bottom: 10
onDocCreated: null
autotable: styles: cellPadding: 2
rowHeight: 12
fontSize: 8
fillColor: 255
textColor: 50
fontStyle: 'normal'
overflow: 'ellipsize'
halign: 'left'
valign: 'middle'
headerStyles: fillColor: [52, 73, 94]
textColor: 255
fontStyle: 'bold'
halign: 'center'
alternateRowStyles: fillColor: 245
tableExport: doc: null
onAfterAutotable: null
onBeforeAutotable: null
onAutotableText: null
onTable: null
outputImages: true
numbers: html: decimalMark: '.'
thousandsSeparator: ','
output: decimalMark: '.',
thousandsSeparator: ','
onCellData: null
onCellHtmlData: null
onMsoNumberFormat: null
outputMode: 'file'
tbodySelector: 'tr'
tfootSelector: 'tr'
theadSelector: 'tr'
tableName: 'myTableName'
type: 'csv'
worksheetName: 'WorksheetName'
```
```ignoreColumn``` can be either an array of indexes (i.e. [0, 2]) or field names (i.e. ["id", "name"]).
* Indexes correspond to the position of the header elements `th` in the DOM starting at 0. (If the `th` elements are removed or added to the DOM, the indexes will be shifted so use the functionality wisely!)
* Field names should correspond to the values set on the "data-field" attribute of the header elements `th` in the DOM.
* "Nameless" columns without data-field attribute will be named by their index number (converted to a string)
To disable formatting of numbers in the exported output, which can be useful for csv and excel format, set the option ``` numbers: output ``` to ``` false ```.
Set the option ``` excelFileFormat ``` to ``` 'xmlss' ``` if you want to export in XML Spreadsheet 2003 file format. Use this format if multiple tables should be exported into a single file. Excel 2000 html format is the default excel file format which has better support of exporting table styles.
The ``` excelstyles ``` option lets you define the css attributes of the original html table cells, that should be taken over when exporting to an excel worksheet (Excel 2000 html format only).
To export in XSLX format [protobi/js-xlsx](https://github.com/protobi/js-xlsx) forked from [SheetJS/js-xlsx](https://github.com/SheetJS/js-xlsx) is used. Please note that the implementation of this format type lets you only export table data, but not any styling information of the html table.
For jspdf options see the documentation of [jsPDF](https://github.com/MrRio/jsPDF) and [jsPDF-AutoTable](https://github.com/simonbengtsson/jsPDF-AutoTable) resp.
There is an extended setting for ``` jsPDF option 'format' ```. Setting the option value to ``` 'bestfit' ``` lets the tableExport plugin try to choose the minimum required paper format and orientation in which the table (or tables in multitable mode) completely fits without column adjustment.
Also there is an extended setting for the ``` jsPDF-AutoTable options 'fillColor', 'textColor' and 'fontStyle'```. When setting these option values to ``` 'inherit' ``` the original css values for background and text color will be used as fill and text color while exporting to pdf. A css font-weight >= 700 results in a bold fontStyle and the italic css font-style will be used as italic fontStyle.
When exporting to pdf the option ``` outputImages ``` lets you enable or disable the output of images that are located in the original html table.
Optional html data attributes
=============================
(can be applied while generating the table that you want to export)
<h3>data-tableexport-display</h3>
```html
<table style="display:none;" data-tableexport-display="always">...</table> -> a hidden table will be exported
<td style="display:none;" data-tableexport-display="always">...</td> -> a hidden cell will be exporte
没有合适的资源?快使用搜索试试~ 我知道了~
tableExport.js实现前端表格的导出功能(支持中文)及打印
共37个文件
js:12个
png:9个
license:4个
5星 · 超过95%的资源 需积分: 46 268 下载量 37 浏览量
2017-11-17
16:25:10
上传
评论 11
收藏 11.28MB ZIP 举报
温馨提示
该插件可以将Html的表格导出成为 JSON, XML, CSV, TSV, TXT, SQL, Word, Excel, PNG,PDF格式。在项目上遇到pdf导出中文乱码问题,经过一天的研究修改了一些js代码解决了pdf导出中文乱码问题,随便融入了一个html打印功能的js,有需要的可以下载来看看。
资源推荐
资源详情
资源评论
收起资源包目录
tableExport.zip (37个子文件)
tableExport
.gitignore 35B
tableExport.js 81KB
tableExport.min.js 31KB
package.json 823B
jquery.js 262KB
LICENSE 1KB
tools
minify2.py 3KB
minify3.py 3KB
libs
js-xlsx
LICENSE 967B
xlsx.core.min.js 411KB
html2canvas
html2canvas.min.js 59KB
LICENSE 1KB
pdfmake
LICENSE 1KB
pdfmake.min.js 1.03MB
vfs_fonts.js 19.26MB
mirza_fonts.js 920KB
jsPDF-AutoTable
jspdf.plugin.autotable.js 15KB
LICENSE.txt 1KB
jsPDF
jspdf.min.js 229KB
MIT-LICENSE.txt 1KB
FileSaver
FileSaver.min.js 2KB
LICENSE.md 1KB
README.md 9KB
bower.json 689B
jQuery.print.js 9KB
test
icons
json.png 6KB
txt.png 3KB
xml.png 3KB
png.png 3KB
pdf.png 3KB
csv.png 3KB
word.png 3KB
sql.png 408B
xls.png 5KB
Thumbs.db 20KB
test.html 8KB
index.html 448KB
共 37 条
- 1
十里夜
- 粉丝: 6
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- IMG_20240425_120538.jpg
- My Complete Genome_6k Base-Pairs of Phenotype SNPs_Complete Raw Data.zip
- qt 的mqtt测试demo
- 移动应用开发教程-zip.zip
- mosquitto-2.018-install-windows-x64
- FTPServer FTP 服务器,绿色免安装,单文件
- 梦畅语音点名软件,上课点名
- 利用ADNI数据集和标签,在tensorflow框架上使用tensorlayer接口,通过架构u-net实现海马体的分割
- Kutools for Word v9.0 office word 插件
- 修复Windows 10 LTSC 2021资源占用率高
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页