html5嵌入csv,csvHtml5

csvHtml5

Since: Buttons 1.0.0

Create and save a CSV file that contains the data from the table (HTML5).

Please note - this property requires the Buttons extension for DataTables.

DescriptionRequires

In order to operate, this button requires the following:

Buttons' HTML5 export button plug-in.

A browser that supports local file saving (IE10+, Chrome, Firefox, Opera).

To ensure that all files required for CSV HTML5 export are included, the DataTables download builder is recommend - select the HTML5 export option.

This button provides the end user with the ability to save the table's data into a locally created Comma Separated Values (CSV) file. That file can then be used by variety of programs including spreadsheet and data analysis applications.

This button requires a reasonably modern browser in order to operate (IE8 and 9 are not supported). For older browsers, the csvFlash button provides similar file creation and save options using the Flash plug-in. The csv button can be used to automatically select between this and the csvFlash buttons based on the browser's capabilities.

Browser support

The API methods used by this button are supported in the following browsers. If the browser being used does not support the requirements for this button, it simply will not be displayed.

Internet Explorer 10+

IE9 and older are not supported as they do not support the FileReader API available in newer browsers.

Edge: Yes

Chrome: Yes

Opera: Yes

Safari: No

Safari does not currently support the ability to download generated files (see WebKit bug 156056). As soon as this has been addressed in Safari it will be released here.

Options

This button can have the following options set in its configuration object to customise its actions and display:NameTypeDefaultaction

Create and save a CSV file.

bom

Since: 1.2.2false

Option to include UTF-8 Byte Order Mark (true) or not (false). This is disabled by default as the Unicode Standard states that the use of a BOM is neither required nor recommended for UTF-8.

charsetnull

Character set to use in the file export. When null is used (default) the document's character set will be read and used (document.characterSet). The addition of a character set can be disabled by setting this property to false.

classNamebuttons-csv buttons-html5

The button's class name. See buttons.buttons.className for details.

customize

Since: 1.1.1undefined

Function that can be used to modify the contents of the exported data. The function takes two parameters, the data as configured by the button and the button's configuration object. The value that the function returns is the value that will be used for the export.

This can be particularly useful if you wish to add a company header or footer, description data or any other information to the exported data.

As of Buttons 1.5.2 this function is passed three parameters:

The CSV data as a string

The button configuration object

A DataTables API instance for the table the button belongs to.

escapeChar"

Character to use as the escape character for CSV data. This will be prefixed to any data found in the fields which matches that set by the fieldBoundary option. It is a configurable option as different applications can require different options - however the default matches RFC4180.

exportOptions{}

Select the data to be gathered from the DataTable for export. This includes options for which columns, rows, ordering and search. Please see the buttons.exportData() method for full details - the object given by this parameter is passed directly into that action to gather the required data.

extension.csv

The extension to give the created file name.

fieldBoundary"

The character(s) used to enclose each field in the plain text representation of the table that is copied to the system's clipboard. This is automatically added at the start and end of each cell's data.

fieldSeparator,

The character(s) used to separate fields in the plain text representation of the table that is copied to the system's clipboard.

filename*

File name to give the created file (plus the extension defined by the extension option). The special character * is automatically replaced with the value read from the host document's title tag.

footerfalse

Indicate if the table footer should be included in the exported data or not.

headertrue

Indicate if the table header should be included in the exported data or not.

newline\n

The character(s) used to separate the lines of data. Please note that on Windows client's the default is \r\n. All other platforms have a default or \n only.

textCSV

The button's display text. The text can be configured using this option (see buttons.buttons.text) or the buttons.copy option of the DataTables language object.

Examples

DataTables initialisation: Use the HTML5 CSV button:$('#myTable').DataTable( {

buttons: [

'csvHtml5'

]

} );

DataTables initialisation: Use the csv button type to automatically select between the Flash and HTML button options.:$('#myTable').DataTable( {

buttons: [

'csv'

]

} );

DataTables initialisation: Use the exportOptions to save all data, regardless of filtering:$('#myTable').DataTable( {

buttons: [

{

extend: 'csvHtml5',

text: 'Copy all data',

exportOptions: {

modifier: {

search: 'none'

}

}

}

]

} );

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值