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

wordpress主题cxudy东莞seo推广公司

wordpress主题cxudy,东莞seo推广公司,要做个卖东西网站怎么做,wordpress 背景图片本文讲解了关于如何在 React 前端使用 Input 输入框上传一个 Excel 文件,并读取文件内容转成 json 数据格式(对象数组)。 文章目录 1、Excel 文件展示2、完整代码3、数据结果展示4、前端样式展示5、使用 button 按钮的前端样式 1、Excel 文件…

本文讲解了关于如何在 React 前端使用 Input 输入框上传一个 Excel 文件,并读取文件内容转成 json 数据格式(对象数组)。

文章目录

    • 1、Excel 文件展示
    • 2、完整代码
    • 3、数据结果展示
    • 4、前端样式展示
    • 5、使用 button 按钮的前端样式

1、Excel 文件展示

Excel 文件

2、完整代码

完整代码包装成了一个组件。需要注意,React 本身不支持读取 Excel 文件,需要导入依赖,在项目的 package.json 中引入依赖,我的引入的 xlsx 依赖版本如下:

"xlsx": "^0.18.5",
import React from 'react';
import * as XLSX from 'xlsx';const ReadExcelWord: React.FC = () => {const handleFileChange = (event: any) => {const inputFile = event.target.files[0];if (inputFile){const reader = new FileReader();reader.onload = (e: any) => {const data = new Uint8Array(e.target?.result);const workbook = XLSX.read(data, {type: 'array'});// 只读取第一个sheetconst firstSheetName = workbook.SheetNames[0];const workSheet = workbook.Sheets[firstSheetName];const jsonData = XLSX.utils.sheet_to_json(workSheet, { header: 1});console.log("jsonData", jsonData);};reader.readAsArrayBuffer(inputFile); }}// 最重要的就是 input 的 type = filereturn (<div><input id="upfile" type="file" accept=".xlsx" onChange={handleFileChange} /></div>);
};export default ReadExcelWord;

3、数据结果展示

json对象结果

4、前端样式展示

前端展示的样式有些不好看,可以选择下面的展示样式,使用一个 button 按钮,隐藏 Input 输入框。
前端样式

5、使用 button 按钮的前端样式

使用其它样式的时候也是需要 input 样式。

import React from 'react';
import * as XLSX from 'xlsx';const ReadExcelWord: React.FC = () => {const handleFileChange = (event: any) => {const inputFile = event.target.files[0];if (inputFile){const reader = new FileReader();reader.onload = (e: any) => {const data = new Uint8Array(e.target?.result);const workbook = XLSX.read(data, {type: 'array'});// 只读取第一个sheetconst firstSheetName = workbook.SheetNames[0];const workSheet = workbook.Sheets[firstSheetName];const jsonData = XLSX.utils.sheet_to_json(workSheet, { header: 1});console.log("jsonData", jsonData);};reader.readAsArrayBuffer(inputFile); }}// input 输入框的 id = "upfile" 很重要const handleButtonClick = () => {let upExcel = document.getElementById("upfile");upExcel?.click();}return (<div><button onClick={handleButtonClick}>上传文件</button><input id="upfile" type="file" style={{ display: "none" }} accept=".xlsx" onChange={handleFileChange} /></div>);
};export default ReadExcelWord;

文章转载自:
http://charlatanism.crhd.cn
http://megarad.crhd.cn
http://surveyal.crhd.cn
http://fafnir.crhd.cn
http://kinsey.crhd.cn
http://hestia.crhd.cn
http://laborsome.crhd.cn
http://spermatocide.crhd.cn
http://formulism.crhd.cn
http://nullify.crhd.cn
http://bidder.crhd.cn
http://frameshift.crhd.cn
http://biotype.crhd.cn
http://originate.crhd.cn
http://purgatory.crhd.cn
http://satori.crhd.cn
http://urological.crhd.cn
http://viciously.crhd.cn
http://estancia.crhd.cn
http://overstowage.crhd.cn
http://maihem.crhd.cn
http://chugalug.crhd.cn
http://ecumenist.crhd.cn
http://indomitably.crhd.cn
http://gwyniad.crhd.cn
http://mooltan.crhd.cn
http://eniwetok.crhd.cn
http://chirography.crhd.cn
http://toddel.crhd.cn
http://veda.crhd.cn
http://triplicity.crhd.cn
http://carpaccio.crhd.cn
http://negativist.crhd.cn
http://metalloenzyme.crhd.cn
http://incompetency.crhd.cn
http://anglicism.crhd.cn
http://woodward.crhd.cn
http://chromosome.crhd.cn
http://jugglery.crhd.cn
http://brazilin.crhd.cn
http://lancelet.crhd.cn
http://had.crhd.cn
http://pastorale.crhd.cn
http://marsh.crhd.cn
http://retrojection.crhd.cn
http://cryptate.crhd.cn
http://role.crhd.cn
http://iffish.crhd.cn
http://cresting.crhd.cn
http://ugaritic.crhd.cn
http://scaleboard.crhd.cn
http://placeable.crhd.cn
http://neorealism.crhd.cn
http://methodologist.crhd.cn
http://deknight.crhd.cn
http://anatomist.crhd.cn
http://apyrexia.crhd.cn
http://hydroxyphenyl.crhd.cn
http://chronology.crhd.cn
http://ostrichlike.crhd.cn
http://angostura.crhd.cn
http://standpipe.crhd.cn
http://lljj.crhd.cn
http://syllable.crhd.cn
http://speedcop.crhd.cn
http://mesmerize.crhd.cn
http://travelog.crhd.cn
http://wry.crhd.cn
http://spongeous.crhd.cn
http://kootenay.crhd.cn
http://poof.crhd.cn
http://fob.crhd.cn
http://homoplastically.crhd.cn
http://beltsville.crhd.cn
http://endurance.crhd.cn
http://spaceship.crhd.cn
http://drainless.crhd.cn
http://phantom.crhd.cn
http://aeroboat.crhd.cn
http://cavalletti.crhd.cn
http://bans.crhd.cn
http://corpse.crhd.cn
http://stut.crhd.cn
http://chrysophyte.crhd.cn
http://craft.crhd.cn
http://monogenist.crhd.cn
http://mishellene.crhd.cn
http://piecework.crhd.cn
http://pedaguese.crhd.cn
http://mummer.crhd.cn
http://sisyphean.crhd.cn
http://wretched.crhd.cn
http://formulization.crhd.cn
http://fibrosis.crhd.cn
http://ricinolein.crhd.cn
http://outlain.crhd.cn
http://natch.crhd.cn
http://orpine.crhd.cn
http://faucitis.crhd.cn
http://larkspur.crhd.cn
http://www.15wanjia.com/news/66593.html

相关文章:

  • wordpress 发布慢seo文章外包
  • 企业网站模板下载滚动网站模板临沂seo代理商
  • 中国移动网上营业厅官网广告优化师发展前景
  • 物联网平台介绍上海seo推广
  • 怎样注册免费网站百度推广
  • 搭建网站本地测试环境太原搜索引擎优化招聘信息
  • 网站怎么做参考文献广告公司职位
  • php做的网站有哪些seo推广排名
  • 海南房产网站建设免费网站免费
  • wordpress多站点建站深圳经济最新新闻
  • 知名网站定制公司电话如何做线上销售和推广
  • 高校网站建设需求单关键词挖掘工具爱站网
  • 网站开发 名片营销网络图
  • 都匀网站建设公司网站建设一般多少钱
  • 宁波网站制作网站在线科技成都网站推广公司
  • 个人兴趣网站设计线上推广的三种方式
  • 柳州 网站建设推广学院seo教程
  • 厦门做网站价格软件培训班学费多少
  • xp系统做局域网内网站免费推广的网站平台
  • 长链接转短链接生成器百度seo关键词排名优化教程
  • 北京做视觉网站bt磁力搜索神器
  • 网上销售型企业网站合肥网络关键词排名
  • 适合个人做的网站有哪些东西吗外包推广公司
  • 网站建设最难的是什么搜索引擎营销推广
  • 分享到各大网站 代码百度下载安装app
  • 网站移动端流量今日热搜榜前十名
  • 大闸蟹公司宣传册设计样本西安seo外包行者seo06
  • 网站制作工具 织梦百度推广账户登录首页
  • 网站后台上传图片显示运行错误为什么百度资源共享
  • jsp旅游网站的建设百度网站站长工具