js将导出的数字转为除以1000在加“KV”

  1. 图片说明
window.onload = function () {
    var exportWordBtn = document.getElementById('exportWord');
    exportWordBtn.onclick=function(){
        var table_ = document.createElement("table");
        table_.style.borderWidth = '1px';
        table_.style.borderColor = 'black';
        table_.style.borderStyle = 'solid';
        var tr,td;
        for(var i=0;i<tableData.length;i++){
            //循环插入元素
            tr = table_.insertRow(table_.rows.length);
            const keys = ['area','voltagr','stationName','deviceName','logStartTime','logEndTime','troubleResult'];
            for(var j=0;j<7;j++){
                td = tr.insertCell(tr.cells.length);
                td.innerHTML = tableData[i][keys[j]];
        }
    }
    //将table表格append到#docx .WordSection1 中
    document.querySelector("#docx .WordSection1").appendChild(table_);
    var docx = document.getElementById('docx');
    //调用export2word函数
    export2Word(docx);
    //调用完成后将生成的表格remove掉
    document.querySelector("#docx .WordSection1").removeChild(table_);
}

}


```![图片说明](https://img-ask.csdn.net/upload/202001/07/1578386161_309722.jpg)![图片说明](https://img-ask.csdn.net/upload/202001/07/1578386168_791517.jpg)
就如图三一个 帮图二导出内容中的220000转为导出显示220KV,救救孩子吧
for(var j=0;j<7;j++){
        td = tr.insertCell(tr.cells.length);
                if(j==1){
                    td.innerHTML = tableData[i][keys[j]]/1000+'kV';
                }else{
                    td.innerHTML = tableData[i][keys[j]];
                }
}