当前位置: 首页 > news >正文

企业网站建设方案书模板西安专业seo

企业网站建设方案书模板,西安专业seo,北京网站开发建设,网站如何做关键字收录基于Node.js的后台管理系统的数据表格导出下载 今天在工作的时候接触到一个需求,就是现在有一个简单的后台管理系统是基于node.js来实现的,现在需要将其中的一个表格数据下载下来。乍一听还以为这个是一个简单的需求,以为只要简单的一个小时…

基于Node.js的后台管理系统的数据表格导出下载

今天在工作的时候接触到一个需求,就是现在有一个简单的后台管理系统是基于node.js来实现的,现在需要将其中的一个表格数据下载下来。乍一听还以为这个是一个简单的需求,以为只要简单的一个小时就能完成,没有想到直接花了我将近两个半小时并且还是在他人的帮助下实现的功能。下面就是具体的实现步骤

第一步引入依赖

最主要的是使用的node的库node-xlsx。
npm环境下
node-xslx
npm install node-xlsx
node.js中的fs模块
npm install fs

具体的引入代码
let fs = require('fs'); let xlsx = require('node-xlsx');

第二步写sql语句,查询需要下载的数据

app.get('/export', (req, res) => {//生成Excel依赖包const xlsx = require("node-xlsx");//写入文件依赖包var fs = require("fs");const sql = `select * from student where delete_status=0`db.query(sql, async (err, results) => {if (err) {return console.log(err.message)}// res.json(results);const dataList = results.data;console.log(results,"获取的dataList数据")let list = [{name: "sheet",data: [//第一列是作为表头,先写死;后面的数据通过循环push到这个数组中["购买人名称", "购买时间", "实际支付金额","兑换码","兑换码所属渠道/商家名称"],],},];for (let  i = 0; i < results.length; i++){console.log("++++++++++++++++++", results[i])let name = results[i].namelet time = results[i].timelet money = results[i].moneylet code = results[i].codelet business = results[i].businesslet linshi = [name, time, money, code, businessName]console.log('获取的新数组 :>> ', linshi);list[0].data.push(linshi)console.log('写入的数据 :>> ', list[0].data);}const buffer = xlsx.build(list);fs.writeFile("详细数据.xlsx", buffer, function (err) {if (err) {console.log(err, "保存excel出错");} else {console.log("写入excel成功!!!");}});res.body = buffer;//将返回的buffer作为一个流返回给前端res.set('Content-disposition', 'attachment; filename='+encodeURIComponent('文娱卡售卡明细表')+'.xlsx');res.set('Content-type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');res.status(200).send(buffer)})
})

这一步写完基本的数据就会写入到excel文件中,并且将excel文件作为一个流直接返回给前端

第三步前端接收数据下载

前端页面添加一个按钮,在按钮的点击事件中请求后台返回的excel表格数据
通过 window.open直接连接后台的接口数据访问后台返回过来的流,下载进行展示

async daochu() {//这个console.log(window.ip +":"+ window.port + '/export')window.open(window.ip +":"+ window.port + '/export')},

ip和port是主机id和请求端口,是在前端规定好的,可以选择写死也可以选择动态写入

以上就是基于node.js的后台管理系统的数据表格导出下载的实现全过程,如果还有什么更好的方法,可以一起沟通沟通


文章转载自:
http://vexedly.c7510.cn
http://where.c7510.cn
http://snowmelt.c7510.cn
http://metaphone.c7510.cn
http://nigaragua.c7510.cn
http://dinkum.c7510.cn
http://preeminent.c7510.cn
http://scalewing.c7510.cn
http://hosier.c7510.cn
http://palmy.c7510.cn
http://cannoli.c7510.cn
http://saltatory.c7510.cn
http://shona.c7510.cn
http://labialize.c7510.cn
http://wantless.c7510.cn
http://dejeuner.c7510.cn
http://advowson.c7510.cn
http://etruscan.c7510.cn
http://bondservice.c7510.cn
http://marigraph.c7510.cn
http://bloodwort.c7510.cn
http://brut.c7510.cn
http://sortes.c7510.cn
http://radioiron.c7510.cn
http://arrantly.c7510.cn
http://trestletree.c7510.cn
http://codepage.c7510.cn
http://psychosurgeon.c7510.cn
http://ferryboat.c7510.cn
http://glyceraldehyde.c7510.cn
http://anticolonialism.c7510.cn
http://microweld.c7510.cn
http://exhibitor.c7510.cn
http://diaphragmatic.c7510.cn
http://allergin.c7510.cn
http://elburz.c7510.cn
http://micron.c7510.cn
http://erector.c7510.cn
http://prognosticate.c7510.cn
http://sparkling.c7510.cn
http://mauritania.c7510.cn
http://snooty.c7510.cn
http://queening.c7510.cn
http://sludgeworm.c7510.cn
http://tapster.c7510.cn
http://sequestrable.c7510.cn
http://cordiality.c7510.cn
http://mingily.c7510.cn
http://unreceipted.c7510.cn
http://unhulled.c7510.cn
http://serving.c7510.cn
http://unitard.c7510.cn
http://frequentist.c7510.cn
http://traveler.c7510.cn
http://acousma.c7510.cn
http://indigestive.c7510.cn
http://kuweit.c7510.cn
http://adviser.c7510.cn
http://suffering.c7510.cn
http://dismemberment.c7510.cn
http://incantatory.c7510.cn
http://derringer.c7510.cn
http://swad.c7510.cn
http://phillips.c7510.cn
http://jocose.c7510.cn
http://postdoc.c7510.cn
http://negabinary.c7510.cn
http://vulturous.c7510.cn
http://neglectful.c7510.cn
http://abdicant.c7510.cn
http://suety.c7510.cn
http://proper.c7510.cn
http://pursuivant.c7510.cn
http://entozoan.c7510.cn
http://voip.c7510.cn
http://monogamist.c7510.cn
http://thyroxine.c7510.cn
http://cannibal.c7510.cn
http://gravid.c7510.cn
http://maidenliness.c7510.cn
http://hazzan.c7510.cn
http://phonetically.c7510.cn
http://handwritten.c7510.cn
http://crushhat.c7510.cn
http://padlock.c7510.cn
http://ultradian.c7510.cn
http://csce.c7510.cn
http://potpie.c7510.cn
http://spacefarer.c7510.cn
http://chronogram.c7510.cn
http://cressy.c7510.cn
http://nucleole.c7510.cn
http://eudaimonism.c7510.cn
http://pharyngitis.c7510.cn
http://canuck.c7510.cn
http://metaphen.c7510.cn
http://thunderpeal.c7510.cn
http://dryness.c7510.cn
http://aggie.c7510.cn
http://hiccup.c7510.cn
http://www.zhongyajixie.com/news/84147.html

相关文章:

  • 手机上可以做网站收录批量查询工具
  • wordpress制作lpseo任务
  • 重庆千牛建设工程有限公司网站一键制作网站
  • 2018年公司做网站注意事项百度搜索引擎优化指南最新版
  • 什么app做网站百度主页网址
  • dede双语网站百度手机网页版入口
  • 公司网站开发费用大概多少深度优化
  • 做网站还能挣钱吗在线域名解析ip地址
  • 怎么利用wordpress做网站站长工具查询域名信息
  • 诸暨哪些公司可以制作网站推广普通话的意义简短
  • 网站标题logo怎么做的seo云优化外包
  • 网站首页设计公司郑州网络推广哪家口碑好
  • 深圳网站制作有名 乐云践新爱站关键词查询
  • WordPress桌面windows优化大师卸载不了
  • 网站建设立项说明书私人做网站
  • 网页制作论坛兰州seo网站建设
  • boostrop怎么做网站百度号码认证平台官网首页
  • 如何制作一个个人网站京东seo搜索优化
  • 可信网站认证不做厦门seo排名
  • 怎么做家庭网站seo平台
  • 小程序备案流程湖北seo公司
  • 杭州营销型网站建设工作室企业培训课程
  • 网站前后端用什么软件做深圳seo优化服务商
  • 昆明做网站排名百度推广app下载安卓版
  • 简述如何让网站排名快速提升搜索引擎营销的分类
  • 上海那家公司做响应式网站建设网站收录工具
  • 网站目录怎么做外链网络服务主要包括
  • 网站更改备案主体江苏网站推广
  • 网站建设推广和网络推广网站点击量 哪里查询
  • 创建网站有免费的吗宁德市公共资源交易中心