$(document).ready(function()
  {
    $('#table').bootstrapTable('refreshOptions', {
        exportOptions: {onMsoNumberFormat: DoOnMsoNumberFormat}
    });
  });
  function DoOnMsoNumberFormat(cell, row, col) {
     return (row > 0 && col == 0) ? '\\@' : '';
  }

ow ,col数值根据你的列号修改,索引是从0开始的
所以 去掉标题栏 row 一般从 1 开始,col根据自己的情况来,或者不判断,所有的单元格都是文本格式
关于 \@ ,参见 tableExport.jquery.plugin#options

  • "\@" 强制为文本格式
  • "0" 数字 无小数
  • "0.000" 数字 三位小数
  • "0%" 百分比 无小数
  • "Percent" 百分比 两位小数
  • 或者 直接闭包
$('#table').tableExport({type: 'excel', onMsoNumberFormat: function(cell, row, col) {
    return (row > 0 && col == 0) ? '\\@' : '';
  }
});

当然了,为了一致性,最好写在js文件的 table.bootstrapTable 配置里面

table.bootstrapTable({
  ...
   exportOptions: {
            type: 'excel', 
           onMsoNumberFormat: function(cell, row, col) {
                return (row > 0 && col == 0) ? '\\@' : '';
           }}
...

) 
点赞(3)

评论列表 共有 0 评论

暂无评论

微信服务号

微信客服

淘宝店铺

support@elephdev.com

发表
评论
Go
顶部