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

国外私人网站游戏推广员平台

国外私人网站,游戏推广员平台,专注大连网站建设,wordpress 新年插件一、安装依赖 npm install xlsx 二、引用依赖 import XLSX from xlsx 三、代码实现 1、注意&#xff1a;函数 analysis 中reader.readAsBinaryString(file)&#xff0c;file的数据格式如图所示 2、示例代码 <!-- 项目使用的前端框架为非流行框架&#xff0c;主要关注…

一、安装依赖

npm install xlsx

二、引用依赖

import XLSX from 'xlsx'

三、代码实现

1、注意:函数 analysis 中reader.readAsBinaryString(file),file的数据格式如图所示

2、示例代码 

<!-- 项目使用的前端框架为非流行框架,主要关注JS实现逻辑即可 -->
<template><div><ta-upload:accept="upload.accept":fileList="upload.fileList":beforeUpload="beforeUpload":remove="uploadRemove"style="margin: 0 8px;"><ta-button>选择附件</ta-button></ta-upload><ta-tablehaveSnsize="small":columns="columns":data-source="dataSource":scroll="{x: 1600, y: 400}"showOverflowTooltip></ta-table></div>
</template>
<script>
import XLSX from 'xlsx'export default {data () {return {columns: [{ title: '医保目录编码', dataIndex: 'hilistCode', width: 300, align: 'center' },{ title: '医保目录名称', dataIndex: 'hilistName', width: 200, align: 'center' },{ title: '参保所属医保区划', dataIndex: 'insuAdmdvs', width: 200, align: 'center' },{ title: '医疗收费项目类别', dataIndex: 'medChrgitmType', width: 200, align: 'center' },{ title: '收费项目等级', dataIndex: 'chrgitmLv', width: 150, align: 'center' },{ title: '目录类别', dataIndex: 'listType', width: 200, align: 'center' },{ title: '限复方使用类型', dataIndex: 'lmtCpndType', width: 200, align: 'center' },{ title: '计价单位', dataIndex: 'prcunt', width: 200, align: 'center' },{ title: '计价说明', dataIndex: 'pricDscr', width: 200, align: 'center' },{ title: '医疗服务项目输出', dataIndex: 'servitemOupt', width: 200, align: 'center' },{ title: '价格构成', dataIndex: 'pricComp', width: 200, align: 'center' },{ title: '费用类型口径', dataIndex: 'feeTypeCali', width: 200, align: 'center' },{ title: '开始时间', dataIndex: 'begndate', width: 200, align: 'center' },{ title: '结束时间', dataIndex: 'enddate', width: 200, align: 'center' }],dataSource: [],upload: {accept: '.xls,.xlsx',fileList: []}}},computed: {uploadTypeErrorMessage () {return `只能上传 ${this.upload.accept.split(',')} 格式的文件`;}},methods: {beforeUpload (file) {if(!['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'].includes(file.type)) {this.$message.error(this.uploadTypeErrorMessage);return false;}this.upload.fileList.length>0?this.upload.fileList.splice(0, 1, file):this.upload.fileList.push(file);this.analysis(file).then(res => { if (res && res.length > 0){let list = [];res[0].sheet.forEach(d => {let data = {};Object.keys(d).filter(k => k!=='序号').forEach(k => { //过滤掉根本不需要的列,根据自己情况写let column = this.columns.find(li => li.title===k);if(column) {data[column.dataIndex] = d[k];}});if(Object.keys(data).length>0) {list.push(data);}});this.dataSource = list;}});return false;},analysis (file){return new Promise(function (resolve) {const reader = new FileReader()reader.onload = function (e){const json = XLSX.read(e.target.result, {type: 'binary'});resolve(json.SheetNames.map(sheetName => {return {sheetName: sheetName,sheet: XLSX.utils.sheet_to_json(json.Sheets[sheetName])};}));};reader.readAsBinaryString(file);});},uploadRemove (file) {let index = this.upload.fileList.findIndex(li =>li.uid===file.uid);if(index> -1) {this.upload.fileList.splice(index, 1);this.dataSource = [];}}},mounted () {this.dataSource = [];this.upload.fileList = [];}
}
</script>

四、参考文章

前端使用xlsx插件读取excel文件数据 - yingzi__block - 博客园

http://www.dtcms.com/wzjs/17794.html

相关文章:

  • 建设好网站能赚到钱吗?今日最新消息
  • 做淘宝客网站需要工商营业执照湖北百度推广电话
  • 男学网站开发正规seo一般多少钱
  • 新网站制作平台广州网站设计公司
  • 请人做网站后台密码郑州百度快照优化排名
  • 咸阳做网站的公司建立网站一般要多少钱
  • 南城微网站建设百度普通收录
  • c#网站开发日期控件2023b站免费推广入口
  • 网站制作公司 深圳站长工具百度百科
  • 怎么自己做直播网站离我最近的广告公司
  • 杭州网站建设设计公司军事新闻今日最新消息
  • 广西做网站建设的公司seo搜索引擎优化介绍
  • 寻找做网站的合作伙伴北京seo是什么意思
  • 成品网站建设流程图网店推广实训报告
  • 买的服务器怎么做网站网络营销公司全网推广公司
  • 深圳住房和建设局网站登录搜索最多的关键词的排名
  • vps打开网站很慢今天微博热搜前十名
  • 公司网站设计与制什么是搜索关键词
  • 无锡华士镇网站建设查询网138网站域名
  • 网站被墙网页制作步骤
  • 中铁建设集团内网登录seo对网站优化
  • 网站的服务器怎么做的百度收录网站要多久
  • 服装设计网站排行榜前十名软文写作技巧有哪些
  • java网站开发属于哪个部门如何提高百度关键词排名
  • 淘宝请人做网站靠谱吗seo排名专业公司
  • 人才招聘网站建设百度人工客服
  • 北京做网站找哪家好百度账号注册中心
  • 私人承接做网站多少钱成都达洱狐网络科技有限公司
  • 网页设计师主要做什么曲靖seo建站
  • 郑州网站建设及优化seo搜索引擎优化工具