【问题标题】:Example: Tablesorter Output widget difference between download and popup special characters示例:Tablesorter 输出小部件下载和弹出特殊字符之间的区别
【发布时间】:2015-07-16 14:37:53
【问题描述】:

我正在使用 tablesorter 的输出小部件将我的表格作为 csv(用于 excel)。该表没有特殊字符的问题。如果我将数据导出为输出,一切都很好。如果我使用下载选项,像& 这样的特殊字符会显示为&(在记事本++ 中看到),因此Excel 决定将其分开,因为有;

有什么帮助吗? 更新: http://jsfiddle.net/abkNM/6503/

谢谢!

【问题讨论】:

  • 你能提供一个例子吗(你可以modify this demo)?表格中的原始标记是否使用像& 这样的html 代码?
  • 嗨,莫蒂,感谢您的回复。我添加了一个例子:jsfiddle.net/abkNM/6503
  • 好的,谢谢。我明白你在说什么,我会调查一下。

标签: csv output tablesorter


【解决方案1】:

好的,我最终添加了一个新的回调函数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 中可用。它将包含在下一次更新中。

【讨论】:

  • 我使用 output_formatContent 替换 CSS 连字符 ­
猜你喜欢
  • 2020-10-07
  • 2017-01-10
  • 1970-01-01
  • 1970-01-01
  • 2021-11-15
  • 2021-01-17
  • 1970-01-01
  • 1970-01-01
  • 2020-01-17
相关资源
最近更新 更多