今天使用table2excel生成表格发现有部分变成了科学计数法,安装百度的教程没搞好

<div data-options="region:'center'" style="height:100px;padding:5px;background:#fff;" >
    <article style="height:100%" id="article">
        <table class="easyui-datagrid" style="height:100%" id="tableData"
           data-options="url:'',fitColumns:true,
               method:'get',
               singleSelect:true,
               striped:true,
               rownumbers:false,
               pagination:true,
               onLoadSuccess:function(data){
                    var HAmount=0;
                    var HCash=0;
                    var HPayByCard=0;
                    var HAlipay=0;
                    var HWeChat=0;
                    var HRelationAmount=0;
                    var HInsurance=0;
                    var HReturnAmount=0;
                    var HReturnCash=0;
                    var HReturnPayByCard=0;
                    var HReturnAlipay=0;
                    var HReturnWeChat=0;
                    var HReturnZHJBH=0;
                for(item in data.rows){
                    HAmount+=Number(data.rows[item].HAmount);
                    HCash+=Number(data.rows[item].HCash);
                    HPayByCard+=Number(data.rows[item].HPayByCard);
                    HAlipay+=Number(data.rows[item].HAlipay);
                    HWeChat+=Number(data.rows[item].HWeChat);
                    HRelationAmount+=Number(data.rows[item].HRelationAmount);
                    HInsurance+=Number(data.rows[item].HInsurance);
                    HReturnAmount+=Number(data.rows[item].HReturnAmount);
                    HReturnCash+=Number(data.rows[item].HReturnCash);
                    HReturnPayByCard+=Number(data.rows[item].HReturnPayByCard);
                    HReturnAlipay+=Number(data.rows[item].HReturnAlipay);
                    HReturnWeChat+=Number(data.rows[item].HReturnWeChat);
                    HReturnZHJBH+=Number(data.rows[item].HReturnZHJBH);
                }
                jQuery('#tableData').datagrid('insertRow',{
                    row:{
                        HBillNum:'合计',
                        HAmount:HAmount.toFixed(2),
                        HCash:HCash.toFixed(2),
                        HPayByCard:HPayByCard.toFixed(2),
                        HAlipay:HAlipay.toFixed(2),
                        HWeChat:HWeChat.toFixed(2),
                        HRelationAmount:HRelationAmount.toFixed(2),
                        HInsurance:HInsurance.toFixed(2),
                        HReturnAmount:HReturnAmount.toFixed(2),
                        HReturnCash:HReturnCash.toFixed(2),
                        HReturnPayByCard:HReturnPayByCard.toFixed(2),
                        HReturnAlipay:HReturnAlipay.toFixed(2),
                        HReturnWeChat:HReturnWeChat.toFixed(2),
                        HReturnZHJBH:HReturnZHJBH.toFixed(2)
                    }
                });
               }
                ">
        <thead>
        <tr style="position: fixed">
            <th data-options="field:'HBillNum'">单据号</th>
            <th data-options="field:'HBillDate'">日期</th>
            <th data-options="field:'HConsignee'">客户</th>
            <th data-options="field:'HAmount'">金额</th>
            <th data-options="field:'HCash'">现金</th>
            <th data-options="field:'HPayByCard'">刷卡</th>
            <th data-options="field:'HAlipay'">支付宝</th>
            <th data-options="field:'HWeChat'">微信支付</th>
            <th data-options="field:'HZHJBH'">招行基本户支付</th>
            <th data-options="field:'HRelationAmount'">欠款</th>
            <th data-options="field:'HInsurance'">无忧保险</th>
            <th data-options="field:'HPostscript'">场地</th>
            <th data-options="field:'HSource'">客户来源</th>
            <th data-options="field:'MaterialNumber',formatter:function(MaterialNumber,row,index){return (MaterialNumber?'\''+MaterialNumber:'')}">框架编号</th>
            <th data-options="field:'MaterialJP'">镜片类型</th>
            <th data-options="field:'HInvContent'">发票</th>
            <th data-options="field:'HArea'">区域</th>
            <th data-options="field:'HRemark'">备注</th>
            <th data-options="field:'HReturnAmount'">退款总金额</th>
            <th data-options="field:'HReturnCash'">退款现金</th>
            <th data-options="field:'HTheOptician'">配镜师</th>
            <th data-options="field:'HOptometrist'">验光师</th>
            <th data-options="field:'HReturnPayByCard'">退款刷卡</th>
            <th data-options="field:'HReturnAlipay'">退款支付宝</th>
            <th data-options="field:'HReturnWeChat'">退款微信支付</th>
            <th data-options="field:'HReturnZHJBH'">退款招行基本户支付</th>
            <th data-options="field:'HOrderNo',formatter:function(HOrderNo,row,index){return (HOrderNo?'\''+HOrderNo:'')}">预约单号</th>
            <th data-options="field:'HHowOos'">服务车辆</th>
            <th data-options="field:'HShippingFee'">预约单金额</th>
        </tr>
        </thead>
    </table>
    </article>
</div>
<script>
    jQuery(document).ready(function () {
        jQuery('#startTime').datebox('setValue',(new Date()).getFullYear()+'-'+((new Date).getMonth()+1)+'-1');
        jQuery('#endTime').datebox('setValue',(new Date()).format('Y-M-d h:i:s'));
    });
    /**
     * 搜索
     * @param tableID
     * @param formID
     */
    function doSearch(tableID,formID) {
        jQuery(tableID).datagrid('options').url='/v1/SO_payment/orderDetail';
        $(tableID).datagrid('load', $(formID).serializeObject());
    }
    function exportExcel(eleID){
        $("#"+eleID).table2excel({
            exclude: ".noExl",
            name: "",
            filename: "日销售明细查询.xls",
        });
    }

</script>

最后在出现科学计数法的th上使用

formatter:function(HOrderNo,row,index){return (HOrderNo?'\''+HOrderNo:'')}
解决这个问题
posted on 2019-04-30 14:03  代码书写人生  阅读(1144)  评论(0编辑  收藏  举报