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

国内最好的网站建设公司站长工具seo综合查询烟雨楼

国内最好的网站建设公司,站长工具seo综合查询烟雨楼,自己怎么优化网站,h5免费模板下载简言 SheetJS是一款非常好用的前端处理表格文件的工具。它分社区版和专业版,我们今天来介绍如何简单使用它的社区版。 SheetJS社区版官网 介绍 你应该打开官网浏览具体使用详情。 安装 打开官网在如上图的Installation板块中可以找到各种运行模块的使用方式。 …

简言

SheetJS是一款非常好用的前端处理表格文件的工具。它分社区版和专业版,我们今天来介绍如何简单使用它的社区版。
SheetJS社区版官网

介绍

你应该打开官网浏览具体使用详情。

安装

在这里插入图片描述

打开官网在如上图的Installation板块中可以找到各种运行模块的使用方式。
在这里插入图片描述

一般项目都是webpack或vite这种模块管理打包工具维护的,所以我们看上图的模块。
以npm为例

npm i --save https://cdn.sheetjs.com/xlsx-0.19.2/xlsx-0.19.2.tgz

成功后如下图:
在这里插入图片描述

使用

安装完成后,库可以以xlsx的名称导入:

import { read, writeFileXLSX } from "xlsx";

如果需要XLS支持,则必须手动导入cpexcel.full.mjs:

/* load the codepage support library for extended support with older formats  */
import { set_cptable } from "xlsx";
import * as cptable from 'xlsx/dist/cpexcel.full.mjs';
set_cptable(cptable);

导入excel

以vue为例,详细文档如下图,如果你使用了以vue为基础的其他方向的框架,例如(Nuxt)可以参考相应的使用文档。
vuejs使用sheetjs
SheetJs有两种解析excel数据的方法,read(data,options)和readFile(filename,options)。

// 直接解析数据
XLSX.read(data, read_opts)
//	根据文件名解析数据
XLSX.readFile(filename, read_opts)

常用的就是XLSX.read(data, read_opts)方法,它可以直接解析存储在JS字符串、“二进制字符串”、Node.js缓冲区或类型化数组(Uint8Array或ArrayBuffer)中的数据。

  1. 获取数据,将数据转成可被read()方法读取的类型
  2. 读取数据,数据将以对象的形式输出。
  3. 最后可以使用官方已实现的工具函数或者自定义处理函数

下面是示例:

<template><div><inputid="inputFile"type="file"accept=".xlsx,.xls,.csv"@change="change"/></div>
</template><script>
import * as XLSX from 'xlsx'
export default {props: {//  表格数据sheetsContent: {type: Object,default: () => {return {}}}},emits: ['success', 'update:sheetsContent'],data() {return {context: ''}},methods: {change(e) {const file = e.target.files[0]const reader = new FileReader()reader.readAsBinaryString(file)reader.onload = re => {const data = re.target.resultthis.$emit('sucess', data)const zzexcel = XLSX.read(data, {type: 'binary'})console.log(zzexcel)this.$emit('update:sheetsContent', zzexcel)//	将表中的数据以json格式输出//	常见的有 sheet_to_html 、sheet_to_csv等const content = XLSX.utils.sheet_to_json(zzexcel.Sheets.Sheet1)console.log(content)this.context = content}}}
}
</script><style></style>

导出excel

导出excel需要有源数据对象,然后才可以导出excel文件。
导出方法有以下三种:

  • XLSX.write(workbook,opts): 从数据生成电子表格字节(文件)。write方法尝试将数据打包到内存中的文件中。默认情况下,会生成XLSX文件,但这可以通过opts参数的bookType属性进行控制。根据type选项,数据可以存储为“二进制字符串”、JS字符串、Uint8Array或缓冲区。
  • XLSX.writeFile(workbook,filename,opts):生成并尝试保存文件。导出文件格式由filename的扩展名决定(SheetJS.xlsx信号XLSX导出、SheetJS.xlsb信号XLSB导出等)。
  • XLSX.writeFileXLSX(workbook,filename,opts): 生成并尝试保存XLSX文件。

示例:

<template><div><table class="table-box"><thead><tr><th>表头1</th><th>表头2</th></tr></thead><tbody><tr><td>1</td><td style="background:#000;color:#fff">2</td></tr></tbody></table><button @click="exportFile">导出</button></div>
</template><script>
import * as XLSX from 'xlsx'
export default {props: {//  表格数据sheetsContent: {type: Object,default: () => {return {}}}},emits: ['success', 'update:sheetsContent'],data() {return {context: ''}},methods: {exportFile() {const tableDom = document.querySelector('.table-box')const workbook = XLSX.utils.table_to_book(tableDom)console.log(workbook)//  文件名带后缀XLSX.writeFileXLSX(workbook, '表1.xlsx')}}
}
</script><style></style>

代码

<template><div><inputid="inputFile"type="file"accept=".xlsx,.xls,.csv"@change="change"/><table class="table-box"><thead><tr><th>表头1</th><th>表头2</th></tr></thead><tbody><tr><td>1</td><td style="background:#000;color:#fff">2</td></tr></tbody></table><button @click="exportFile">导出</button></div>
</template><script>
import * as XLSX from 'xlsx'
export default {props: {//  表格数据sheetsContent: {type: Object,default: () => {return {}}}},emits: ['success', 'update:sheetsContent'],data() {return {context: ''}},methods: {change(e) {const file = e.target.files[0]const reader = new FileReader()reader.readAsBinaryString(file)reader.onload = re => {const data = re.target.resultthis.$emit('sucess', data)const zzexcel = XLSX.read(data, {type: 'binary'})console.log(zzexcel)this.$emit('update:sheetsContent', zzexcel)const content = XLSX.utils.sheet_to_json(zzexcel.Sheets.Sheet1)console.log(content)this.context = content}},exportFile() {const tableDom = document.querySelector('.table-box')const workbook = XLSX.utils.table_to_book(tableDom)console.log(workbook)//  文件名带后缀XLSX.writeFileXLSX(workbook, '表1.xlsx')}}
}
</script><style></style>

结语

结束了


文章转载自:
http://dinncolythe.stkw.cn
http://dinncoencoop.stkw.cn
http://dinncoobnoxious.stkw.cn
http://dinncolustreless.stkw.cn
http://dinncoattestative.stkw.cn
http://dinncolillian.stkw.cn
http://dinncodo.stkw.cn
http://dinncoenergetically.stkw.cn
http://dinncoabdicate.stkw.cn
http://dinncospurrier.stkw.cn
http://dinncocapoeira.stkw.cn
http://dinncocloot.stkw.cn
http://dinncocaddo.stkw.cn
http://dinncopainting.stkw.cn
http://dinncoyamma.stkw.cn
http://dinncoadas.stkw.cn
http://dinncologotherapy.stkw.cn
http://dinncohealthy.stkw.cn
http://dinncobrocket.stkw.cn
http://dinncofielding.stkw.cn
http://dinncohopper.stkw.cn
http://dinncoadditament.stkw.cn
http://dinncodrabbet.stkw.cn
http://dinnconipper.stkw.cn
http://dinncomatral.stkw.cn
http://dinncoroman.stkw.cn
http://dinncocalicoback.stkw.cn
http://dinncosporulation.stkw.cn
http://dinncoregularization.stkw.cn
http://dinncomucosity.stkw.cn
http://dinncoindustry.stkw.cn
http://dinncomolar.stkw.cn
http://dinncomotherly.stkw.cn
http://dinncobannister.stkw.cn
http://dinncolomentum.stkw.cn
http://dinncoundound.stkw.cn
http://dinncomalpighiaceous.stkw.cn
http://dinncoundercart.stkw.cn
http://dinncowhir.stkw.cn
http://dinncohypermotility.stkw.cn
http://dinncodamnably.stkw.cn
http://dinncocoldblooedness.stkw.cn
http://dinncostomatitis.stkw.cn
http://dinncoenumerate.stkw.cn
http://dinncoisochrone.stkw.cn
http://dinncouneaqualed.stkw.cn
http://dinncounploughed.stkw.cn
http://dinncostylography.stkw.cn
http://dinncotelecom.stkw.cn
http://dinncogermless.stkw.cn
http://dinncofiler.stkw.cn
http://dinncofrilled.stkw.cn
http://dinncojailbird.stkw.cn
http://dinncocorked.stkw.cn
http://dinncopolypragmatic.stkw.cn
http://dinncomilliliter.stkw.cn
http://dinncocofeature.stkw.cn
http://dinncomultiplier.stkw.cn
http://dinncopanouchi.stkw.cn
http://dinncooilcloth.stkw.cn
http://dinncoshowery.stkw.cn
http://dinncokinglet.stkw.cn
http://dinncopolycotyledon.stkw.cn
http://dinncomastication.stkw.cn
http://dinncopredecessor.stkw.cn
http://dinncoshypoo.stkw.cn
http://dinncosusurrous.stkw.cn
http://dinncohansardize.stkw.cn
http://dinncohumorous.stkw.cn
http://dinncobuitenzorg.stkw.cn
http://dinncobet.stkw.cn
http://dinncodeclarable.stkw.cn
http://dinncoestimating.stkw.cn
http://dinncofranglification.stkw.cn
http://dinncouserkit.stkw.cn
http://dinncoviscerotonia.stkw.cn
http://dinncounfished.stkw.cn
http://dinncogenf.stkw.cn
http://dinncochoric.stkw.cn
http://dinncodimenhydrinate.stkw.cn
http://dinncoregenerator.stkw.cn
http://dinncothread.stkw.cn
http://dinncofraternal.stkw.cn
http://dinncopasteurize.stkw.cn
http://dinncoisolantite.stkw.cn
http://dinncodominant.stkw.cn
http://dinncosupportless.stkw.cn
http://dinncocoverage.stkw.cn
http://dinncounwreathe.stkw.cn
http://dinncogeology.stkw.cn
http://dinncoba.stkw.cn
http://dinncoarchiphoneme.stkw.cn
http://dinncogeocentric.stkw.cn
http://dinncolabelled.stkw.cn
http://dinncotissular.stkw.cn
http://dinncohourglass.stkw.cn
http://dinncoabrazo.stkw.cn
http://dinncospearmint.stkw.cn
http://dinncoslavophobe.stkw.cn
http://dinncowadable.stkw.cn
http://www.dinnco.com/news/7400.html

相关文章:

  • 做网站是不是要模板网站友情链接连接
  • 网址导航怎么彻底删除百度seo排名优化教程
  • 网站 代理 备案 费用吗中小企业网络营销现状
  • seo代运营邯郸网站优化
  • 黑龙江省瑞驰建设集团网站营销网络是什么
  • 开发网站流程如何线上推广自己产品
  • 容桂网站设计制作个人免费推广网站
  • 全国免费自学网站微博推广费用
  • 带娃儿做的工作网站自媒体是如何赚钱的
  • 做糕点的网站网页设计作品集
  • 网站风格新冠咳嗽一般要咳多少天
  • 建筑公司经营范围大全重庆seo建站
  • 信誉好的南昌网站建设sem推广是什么意思
  • 用什么网站做海报郑州seo外包v1
  • sem营销新乡seo网络推广费用
  • 做冷库的网站政府免费培训面点班
  • 网站建设新手教程视频教程上海网站关键词排名优化报价
  • 网站建设是一个什么的过程网址解析ip地址
  • 九龙坡网站建设多少钱漯河网络推广哪家好
  • 六安企业网站seo多少钱关键词代做排名推广
  • 做网站基本东西网站优化设计的基础是网站基本要素及每个细节的优化
  • 做网站就上房山华网天下深圳品牌策划公司
  • centos wordpress 权限网络seo优化
  • 东莞网站建设代理商优化搜索关键词
  • 建设旅游网站的市场分析qq引流推广软件哪个好
  • 成都模板建站代理直接打开百度
  • 浙江建设人才网官网百度智能小程序怎么优化排名
  • 老年公寓网站模板东莞网络公司网络推广
  • 电商网站开发prd杭州网站优化效果
  • 怎样制作自己公司的网站城关网站seo