中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

做新聞網(wǎng)站數(shù)據(jù)能讓手機(jī)流暢到爆的軟件

做新聞網(wǎng)站數(shù)據(jù),能讓手機(jī)流暢到爆的軟件,php網(wǎng)站開發(fā)哪個(gè)培訓(xùn)學(xué)校好,婚紗攝影網(wǎng)站的設(shè)計(jì)思路前言:開發(fā)過程中遇到的一些業(yè)務(wù)場(chǎng)景,如果第三方不讓使用,后端不提供接口,就只能拿到table數(shù)據(jù)(Array),實(shí)現(xiàn)excel文件下載。 廢話不多說,直接上代碼,方法后續(xù)自行封裝即可: functio…

前言:開發(fā)過程中遇到的一些業(yè)務(wù)場(chǎng)景,如果第三方不讓使用,后端不提供接口,就只能拿到table數(shù)據(jù)(Array),實(shí)現(xiàn)excel文件下載。

廢話不多說,直接上代碼,方法后續(xù)自行封裝即可:

function downLoadExcel(){console.log("下載excel");var table = [{index:"1",name:"Jerry",username:"杰瑞1",father:"你爸爸"},{index:"2",name:"Jerry",username:"杰瑞2",father:"你爸爸"},{index:"3",name:"Jerry",username:"杰瑞3",father:"你爸爸"},{index:"4",name:"Jerry",username:"杰瑞4",father:"你爸爸"},{index:"5",name:"Jerry",username:"杰瑞5",father:"你爸爸"},{index:"6",name:"Jerry",username:"杰瑞6",father:"你爸爸"},{index:"7",name:"Jerry",username:"杰瑞7",father:"你爸爸"},{index:"8",name:"Jerry",username:"杰瑞8",father:"你爸爸"},{index:"9",name:"Jerry",username:"杰瑞9",father:"你爸爸"},{index:"10",name:"Jerry",username:"杰瑞10",father:"你爸爸"},{index:"11",name:"Jerry",username:"杰瑞11",father:"你爸爸"},{index:"12",name:"Jerry",username:"杰瑞11",father:""},]console.log("長度",table.length)console.log("數(shù)據(jù)源是什么1",JSON.parse(JSON.stringify(table)))let JSONData = JSON.parse(JSON.stringify(table));let ShowLabel = ['序號(hào)', '英文名', '中文名','父親','母親','兒子','孫子','外公','外婆'];//先轉(zhuǎn)化jsonlet arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;console.log("數(shù)據(jù)源是什么",arrData)// 給數(shù)組內(nèi)容換好位置arrData.forEach(item => {let obj = {index: item.index,name: item.name ? item.name : '',username: item.username,father:item.father?item.father:'',};table.push(obj);});let excel = '<table>';//設(shè)置表頭let row = '<tr>';for (let i = 0; i < ShowLabel.length; i++) {row += '<td>' + ShowLabel[i] + '</td>';}//換行excel += row + '</tr>';//設(shè)置數(shù)據(jù)for (let i = 0; i < (table.length)/2; i++) {console.log("遍歷了"+i+"次")let row = '<tr>';for (let index in table[i]) {let value = table[i][index];if (index === 'imei') {// 當(dāng)數(shù)字超過一定長度就科學(xué)計(jì)數(shù)法可以使用style='mso-number-format:"\@"'// 這個(gè)屬性指定某單元格的數(shù)據(jù)格式,避免Excel自動(dòng)轉(zhuǎn)換格式row += `<td style='mso-number-format:\"\\@\"'>${value}</td>`;} else {row += '<td>' + value + '</td>';}}excel += row + '</tr>';}excel += '</table>';let excelFile ="<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>";excelFile +='<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-excel';excelFile += '; charset=UTF-8">';excelFile += '<head>';excelFile += '<!--[if gte mso 9]>';excelFile += '<xml>';excelFile += '<x:ExcelWorkbook>';excelFile += '<x:ExcelWorksheets>';excelFile += '<x:ExcelWorksheet>';excelFile += '<x:Name>';excelFile += '{worksheet}';excelFile += '</x:Name>';excelFile += '<x:WorksheetOptions>';excelFile += '<x:DisplayGridlines/>';excelFile += '</x:WorksheetOptions>';excelFile += '</x:ExcelWorksheet>';excelFile += '</x:ExcelWorksheets>';excelFile += '</x:ExcelWorkbook>';excelFile += '</xml>';excelFile += '<![endif]-->';excelFile += '</head>';excelFile += '<body>';excelFile += excel;excelFile += '</body>';excelFile += '</html>';let uri = 'data:application/vnd.ms-excel;charset=utf-8,' + encodeURIComponent(excelFile);let link = document.createElement('a');link.href = uri;link.style = 'visibility:hidden';link.download = '表格下載.xls';document.body.appendChild(link);link.click();document.body.removeChild(link);console.log("下載成功");}

效果截圖:
在這里插入圖片描述

http://www.risenshineclean.com/news/9306.html

相關(guān)文章:

  • 投稿平臺(tái)在哪里找寧波seo推薦
  • 網(wǎng)站建設(shè)電腦配置深圳網(wǎng)站設(shè)計(jì)十年樂云seo
  • 工信部網(wǎng)站備案系統(tǒng)登錄免費(fèi)的網(wǎng)絡(luò)推廣平臺(tái)
  • html5網(wǎng)站模板移動(dòng)端百度關(guān)鍵詞優(yōu)化查詢
  • 車牌照丟失能在網(wǎng)站做嗎公司關(guān)鍵詞seo
  • 網(wǎng)站平臺(tái)建設(shè)方案策劃書seo培訓(xùn)學(xué)院官網(wǎng)
  • 想建立什么網(wǎng)站嗎搜索引擎優(yōu)化指的是什么
  • 網(wǎng)站域名變更后怎樣操作廣州網(wǎng)站設(shè)計(jì)實(shí)力樂云seo
  • 做網(wǎng)站ie緩存怎么讓百度快速收錄網(wǎng)站
  • 什么是移動(dòng)端網(wǎng)站適配軟文營銷的概念
  • 手機(jī)版wordpressseo內(nèi)鏈優(yōu)化
  • 商丘市網(wǎng)廣州網(wǎng)站優(yōu)化公司排名
  • 怎么學(xué)做網(wǎng)站制作長沙網(wǎng)紅奶茶
  • 找別人做網(wǎng)站需要什么信息優(yōu)秀網(wǎng)站設(shè)計(jì)欣賞
  • 國外h5制作網(wǎng)站網(wǎng)絡(luò)輿情優(yōu)化公司
  • 小企業(yè)官方網(wǎng)站制作湖南長沙seo教育
  • 一級(jí)a做爰片免費(fèi)網(wǎng)站國語版的軟件怎么推廣
  • 高校門戶網(wǎng)站建設(shè)問題火蝠電商代運(yùn)營靠譜嗎
  • 免費(fèi)網(wǎng)站模板之家獨(dú)立站優(yōu)化
  • 高中生做網(wǎng)站網(wǎng)頁百度網(wǎng)站登錄入口
  • 做網(wǎng)站可以用什么數(shù)據(jù)庫外貿(mào)營銷型網(wǎng)站
  • 網(wǎng)站建設(shè)項(xiàng)目報(bào)價(jià)友情鏈接網(wǎng)站大全
  • 孝義網(wǎng)站建設(shè)近兩年網(wǎng)絡(luò)營銷成功案例
  • 網(wǎng)頁版qq郵箱怎么發(fā)文件北京seo加盟
  • 網(wǎng)站目錄不能訪問百度站長工具網(wǎng)站提交
  • wordpress前臺(tái)出現(xiàn)舊版文件夾廣州抖音seo
  • 優(yōu)酷網(wǎng)站誰做的seo智能優(yōu)化公司
  • 做招聘網(wǎng)站怎么樣寧波網(wǎng)站seo診斷工具
  • 工會(huì)網(wǎng)站建設(shè)管理工作總結(jié)軟文營銷范文
  • 企業(yè)logo圖片上海seo外包