前端导出文件换行

if (Yonlink.Export == true) {
                    $("#exportPoint").show();
                    $("#exportPoint").unbind().click(function () {
                        var _txt = "";
                        var pointIndex = [];
                        if (queryResult) {
                            for (var n = 0; n < queryResult.length; n++) {
                                pointStr = queryResult[n].geometry.rings[0];
                                pointIndex[n] = pointStr.length;
                                var indexNum = 0;
                                for (let k = 0; k < pointIndex.length - 1; k++) {
                                    indexNum += pointIndex[k];
                                }
                                for (var m = 0; m < pointStr.length; m++) {
                                    var xStr = pointStr[m][0].toFixed(4);
                                    var yStr = pointStr[m][1].toFixed(4);
                                    if (n > 1) {
                                        _txt += indexNum + m + 1 + "," + "0," + yStr + "," + xStr + ",0";
                                        _txt += "
"; } else if (n == 1) { _txt += pointIndex[0] + m + 1 + "," + "0," + yStr + "," + xStr + ",0"; _txt += "
"; } else { _txt += m + 1 + "," + "0," + yStr + "," + xStr + ",0"; _txt += "
"; } } } var isIE = !!window.ActiveXObject || "ActiveXObject" in window; if (isIE) { var strHTML = _txt var winSave = window.open(); winSave.document.open("text", "utf-8"); winSave.document.write(strHTML); winSave.document.execCommand("SaveAs", true, "coordinate.txt"); winSave.close(); } else { var elHtml = _txt; var mimeType = 'text/plain'; $('#createInvote').attr('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml)); document.getElementById('createInvote').click(); } } }) }

你可能感兴趣的:(前端导出文件换行)