jQuery Tablesorter-导出日期而不是浮点数 [英] jQuery Tablesorter - exports dates instead of floats

查看:123
本文介绍了jQuery Tablesorter-导出日期而不是浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

演示

当我将表格导出到csv时,浮点数用小数点."分隔. 在excel中,这些值将转换为日期,而不是像HTML表中那样保留它们.

When i export my table to csv the floats are separated with decimal dot "." and in excel the values are converted to dates instead of keeping them like they are in HTML table.

有没有一种方法可以将点替换为十进制逗号,"

Is there a way to replace the dots with decimal comma ","

$(function () {

    var $table = $('table');

    $('.download').click(function(){
        $table.trigger('outputTable');
    });

    $table.tablesorter({
        theme: 'blue',
        widgets: ['zebra', 'output'],
        widgetOptions : { output_delivery : 'd', output_separator     : ';'}
    });
});

推荐答案

您可以配置output_formatContent,如下所示:

You can config a output_formatContent, like this:

$(function() {
  var $table = $('table');

  $('.download').click(function() {
    $table.trigger('outputTable');
  });

  $table.tablesorter({
    theme: 'blue',
    widgets: ['zebra', 'output'],
    widgetOptions: {
      output_delivery: 'd',
      output_separator: ';',
      output_formatContent: function(c, wo, data) {
        if (c.parsers[data.$cell['0'].cellIndex].type !== 'numeric')
          return data.content;
        return data.content.replace(/\./ig, ',');
      }
    }
  });
});

您可以在此处查看: http://jsfiddle.net/abkNM/8781/

这篇关于jQuery Tablesorter-导出日期而不是浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆