示例:Tablesorter 输出小部件下载和弹出特殊字符之间的区别
Example: Tablesorter Output widget difference between download and popup special characters
我正在使用 tablesorter 的输出小部件将我的 table 获取为 csv(对于 excel)。 table 对特殊字符没有问题。如果我将数据导出为输出,一切都很好。如果我使用下载选项特殊字符,如 &
显示为 &
(在 Notepad++ 中看到),因此 Excel 决定将其分开,因为有 ;
有什么帮助吗?
更新:
http://jsfiddle.net/abkNM/6503/
谢谢!
好的,我最终添加了一个新的回调函数 output_formatContent
*。按如下方式使用 (demo):
output_formatContent: function (config, widgetOptions, data) {
// data.isHeader (boolean) = true if processing a header cell
// data.$cell = jQuery object of the cell currently being processed
// data.content = processed cell content
// (spaces trimmed, quotes added/replaced, etc)
// **********
// use data.$cell.html() to get the original cell content
return data.content.replace(/&/g, '&');
}
如果您想替换所有 HTML 代码,请查看 Mathias Bynens he,其工作方式如下:
output_formatContent : function( c, wo, data ) {
// replace all HTML shortcut codes
// (e.g. 'foo © bar ≠ baz 𝌆 qux' becomes 'foo © bar ≠ baz qux' )
return he.decode( data.content );
}
* 注意:新的输出小部件回调目前仅在 master branch of the tablesorter repository 中可用。它将包含在下一次更新中。
我正在使用 tablesorter 的输出小部件将我的 table 获取为 csv(对于 excel)。 table 对特殊字符没有问题。如果我将数据导出为输出,一切都很好。如果我使用下载选项特殊字符,如 &
显示为 &
(在 Notepad++ 中看到),因此 Excel 决定将其分开,因为有 ;
有什么帮助吗? 更新: http://jsfiddle.net/abkNM/6503/
谢谢!
好的,我最终添加了一个新的回调函数 output_formatContent
*。按如下方式使用 (demo):
output_formatContent: function (config, widgetOptions, data) {
// data.isHeader (boolean) = true if processing a header cell
// data.$cell = jQuery object of the cell currently being processed
// data.content = processed cell content
// (spaces trimmed, quotes added/replaced, etc)
// **********
// use data.$cell.html() to get the original cell content
return data.content.replace(/&/g, '&');
}
如果您想替换所有 HTML 代码,请查看 Mathias Bynens he,其工作方式如下:
output_formatContent : function( c, wo, data ) {
// replace all HTML shortcut codes
// (e.g. 'foo © bar ≠ baz 𝌆 qux' becomes 'foo © bar ≠ baz qux' )
return he.decode( data.content );
}
* 注意:新的输出小部件回调目前仅在 master branch of the tablesorter repository 中可用。它将包含在下一次更新中。