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

单位网站等级保护必须做吗网站seo标题优化技巧

单位网站等级保护必须做吗,网站seo标题优化技巧,手机app制作用什么软件,最好的网站建设文章目录 功能简介简单代码实现效果参考 功能简介 通过LuckyExcel的transformExcelToLucky方法, 我们可以把一个文件直接转成LuckySheet需要的json字符串, 之后我们就可以用LuckySheet预览excelLuckyExcel只能解析xlsx格式的excel文件,因此对…

文章目录

    • 功能简介
    • 简单代码实现
    • 效果
    • 参考

功能简介

  1. 通过LuckyExcel的transformExcelToLucky方法, 我们可以把一个文件直接转成LuckySheet需要的json字符串, 之后我们就可以用LuckySheet预览excel
  2. LuckyExcel只能解析xlsx格式的excel文件,因此对于xls和csv的格式,我们需要通过XLSX来转化成xlsx格式,但在转化过程中会丢失样式
  3. 对于excel中存在很多的空白行,在显示的时候可能会出现卡顿,所以我们需要将过多的空白行移除

简单代码实现

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Excel File Upload and Preview with Luckysheet</title>
</head>
<body><!-- 文件上传控件 -->
<input type="file" id="fileUpload"/><!-- Luckysheet 的容器 -->
<div id="luckysheet" style="position: relative; width: 100%; height: 500px;"></div>
<script src="https://cdn.jsdelivr.net/npm/xlsx/dist/xlsx.full.min.js"></script><link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/plugins/css/pluginsCss.css'/>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/plugins/plugins.css'/>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/css/luckysheet.css'/>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/assets/iconfont/iconfont.css'/>
<script src="https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/plugins/js/plugin.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luckysheet@latest/dist/luckysheet.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/luckyexcel/dist/luckyexcel.umd.js"></script><script>const _xlsxType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';const  _xlsType = 'application/vnd.ms-excel';const  _csvType = 'text/csv';//如果后端是以流的方式返回,可以调用这个方法const handleExcel = (res, fileName) => {const file = getExcelFile(res, fileName);handleExcelFile(file);}// 获取Excel文件const getExcelFile = (res, fileName) => {// 根据文件后缀名判断文件类型if (fileName.endsWith('.xlsx')) {return new File([res], fileName, {type: _xlsxType});} else if (fileName.endsWith('.xls')) {return new File([res], fileName, {type: _xlsType});} else if (fileName.endsWith('.csv')) {return new File([res], fileName, {type: _csvType});} else {throw new Error("Unsupported file type");}}// 处理Excel文件const handleExcelFile = (file) => {const fileName = file.name;// 根据文件后缀名判断文件类型并进行处理if (fileName.endsWith('.xlsx')) {console.log("handle excel for xlsx type..", fileName);handleExcelForXlsxType(file, fileName);} else if (fileName.endsWith('.xls') || fileName.endsWith('.csv')) {console.log("handle excel for xls or csv type..", fileName);handleExcelForXlsAndCsvType(file, fileName);} else {throw new Error("Unsupported file type");}}// 处理xlsx类型的Excel文件const handleExcelForXlsxType = (file, fileName) => {const reader = new FileReader();reader.onload = function (event) {const data = new Uint8Array(event.target.result);const workbook = XLSX.read(data, {type: 'array'});// 获取Excel文件中的最大行数let maxRowCountFromExcel = getMaxRowCountFromExcel(workbook);// 如果行数大于100000,则处理Excel文件中的空行if (maxRowCountFromExcel > 1000000) {console.log("excel file has too many blank row..", maxRowCountFromExcel);handleBlankRowForExcelWithTooManyBlankRow(workbook);const xlsxFile = toXlsxExcelFile(workbook, fileName);createLuckySheet(xlsxFile);} else {createLuckySheet(file);}};reader.readAsArrayBuffer(file);}// 处理xls和csv类型的Excel文件const handleExcelForXlsAndCsvType = (file, fileName) => {const reader = new FileReader();// 读取文件完成后的回调函数reader.onload = function (event) {const data = new Uint8Array(event.target.result);// 读取Excel文件内容const workbook = XLSX.read(data, {type: 'array'});// 将Excel文件转换为xlsx类型const xlsxFile = toXlsxExcelFile(workbook, fileName);// 处理xlsx类型的Excel文件handleExcelForXlsxType(xlsxFile, fileName);};// 以ArrayBuffer的形式读取文件reader.readAsArrayBuffer(file);}/ 创建Luckysheetconst createLuckySheet = (file) => {// 销毁已存在的Luckysheetwindow.luckysheet.destroy();// 将Excel文件转换为Luckysheet的jsonLuckyExcel.transformExcelToLucky(file, function (exportJson, luckysheetfile) {if (exportJson.sheets == null || exportJson.sheets.length === 0) {throw new Error("Failed to load excel file");}// 创建Luckysheet的配置项const options = {container: 'luckysheet',data: exportJson.sheets, // title: exportJson.info.name,// userInfo: exportJson.info.name.creator,column: 10,row: 10,showinfobar: false,sheetFormulaBar: true,showConfigWindowResize: false};// 创建Luckysheetwindow.luckysheet.create(options);});}// 获取Excel文件中的最大行数const getMaxRowCountFromExcel = (workbook) => {let maxRowCount = 0;if (workbook.SheetNames == null || workbook.SheetNames.length === 0) {return maxRowCount;}// 遍历每个sheet,获取最大行数workbook.SheetNames.forEach(sheetName => {const worksheet = workbook.Sheets[sheetName];if (worksheet['!ref'] === undefined) {return;}const range = XLSX.utils.decode_range(worksheet['!ref']);maxRowCount = maxRowCount + range.e.r;});console.log("max:", maxRowCount)return maxRowCount;}const reduceBlankRow = (row, range, worksheet) => {// 从给定的行开始,向上遍历到工作表的起始行while (row > range.s.r) {// 假设当前行是空的let allEmpty = true;// 遍历当前行的所有列for (let col = range.s.c; col <= range.e.c; col++) {// 获取当前单元格的引用const cell_ref = XLSX.utils.encode_cell({c: col, r: row});// 如果当前单元格不为空,则将allEmpty设置为false并跳出循环if (worksheet[cell_ref]) {allEmpty = false;break;}}// 如果当前行是空的,则将行数减一,否则跳出循环if (allEmpty) {row--;} else {break;}}// 更新工作表范围的结束行range.e.r = row;// 更新工作表的范围引用worksheet['!ref'] = XLSX.utils.encode_range(range.s, range.e);}// 处理Excel文件中的空行const handleBlankRowForExcelWithTooManyBlankRow = (workbook) => {if (workbook.SheetNames == null || workbook.SheetNames.length === 0) {return;}// 遍历每个sheet,处理空行workbook.SheetNames.forEach(sheetName => {const worksheet = workbook.Sheets[sheetName];if (worksheet['!ref'] === undefined) {return;}const range = XLSX.utils.decode_range(worksheet['!ref']);let row = range.e.r;reduceBlankRow(row, range, worksheet);});}// 将Excel文件转换为xlsx类型const toXlsxExcelFile = (workbook, fileName) => {const newWorkbook = XLSX.write(workbook, {bookType: 'xlsx', type: 'binary'});const data = new Uint8Array(newWorkbook.length);for (let i = 0; i < newWorkbook.length; i++) {data[i] = newWorkbook.charCodeAt(i);}return new File([data], fileName, {type: _xlsxType});}// 文件上传控件的change事件处理函数document.getElementById('fileUpload').addEventListener('change', function (e) {// 获取上传的文件const file = e.target.files[0];// 处理Excel文件handleExcelFile(file);});</script></body>
</html>

效果

在这里插入图片描述

参考

https://juejin.cn/post/7211805251216031801
https://segmentfault.com/a/1190000043720845
https://juejin.cn/post/7232524757525659708
https://blog.csdn.net/q2qwert/article/details/130908294
https://www.cnblogs.com/ajaemp/p/12880847.html
https://blog.csdn.net/weixin_40775791/article/details/135409716
https://blog.csdn.net/u013113491/article/details/129106671


文章转载自:
http://tacky.rbzd.cn
http://circumlittoral.rbzd.cn
http://taenia.rbzd.cn
http://bothy.rbzd.cn
http://rimal.rbzd.cn
http://aroynt.rbzd.cn
http://moabite.rbzd.cn
http://undulant.rbzd.cn
http://downwelling.rbzd.cn
http://brannigan.rbzd.cn
http://disparate.rbzd.cn
http://briefs.rbzd.cn
http://exquay.rbzd.cn
http://fertile.rbzd.cn
http://naphthalize.rbzd.cn
http://dard.rbzd.cn
http://ideaistic.rbzd.cn
http://granola.rbzd.cn
http://sinless.rbzd.cn
http://bard.rbzd.cn
http://trappy.rbzd.cn
http://whimper.rbzd.cn
http://catchphrase.rbzd.cn
http://bezant.rbzd.cn
http://quencher.rbzd.cn
http://rose.rbzd.cn
http://interindividual.rbzd.cn
http://usufructuary.rbzd.cn
http://hollowly.rbzd.cn
http://stimulating.rbzd.cn
http://trunkfish.rbzd.cn
http://sice.rbzd.cn
http://sheena.rbzd.cn
http://avalement.rbzd.cn
http://psychosomatry.rbzd.cn
http://lae.rbzd.cn
http://tobruk.rbzd.cn
http://proficiency.rbzd.cn
http://vector.rbzd.cn
http://heedful.rbzd.cn
http://solstice.rbzd.cn
http://debridement.rbzd.cn
http://lazyish.rbzd.cn
http://calicoback.rbzd.cn
http://salute.rbzd.cn
http://laboursome.rbzd.cn
http://anasarca.rbzd.cn
http://druze.rbzd.cn
http://crump.rbzd.cn
http://sarcastically.rbzd.cn
http://rivulet.rbzd.cn
http://ally.rbzd.cn
http://yakow.rbzd.cn
http://antiapartheid.rbzd.cn
http://gownsman.rbzd.cn
http://whiz.rbzd.cn
http://deject.rbzd.cn
http://capsulate.rbzd.cn
http://untouched.rbzd.cn
http://wringer.rbzd.cn
http://fridge.rbzd.cn
http://avens.rbzd.cn
http://manlike.rbzd.cn
http://frondeur.rbzd.cn
http://phonemic.rbzd.cn
http://amobarbital.rbzd.cn
http://rosery.rbzd.cn
http://rathaus.rbzd.cn
http://misarrange.rbzd.cn
http://botswana.rbzd.cn
http://destructional.rbzd.cn
http://wider.rbzd.cn
http://intransitivize.rbzd.cn
http://venturesome.rbzd.cn
http://xystarch.rbzd.cn
http://semiuncial.rbzd.cn
http://lapstreak.rbzd.cn
http://fatness.rbzd.cn
http://concertante.rbzd.cn
http://chiliad.rbzd.cn
http://ambiance.rbzd.cn
http://symmetrical.rbzd.cn
http://pollster.rbzd.cn
http://brimming.rbzd.cn
http://oxtail.rbzd.cn
http://ruminatively.rbzd.cn
http://nomocracy.rbzd.cn
http://endoparasite.rbzd.cn
http://rectificatory.rbzd.cn
http://sickish.rbzd.cn
http://furnishment.rbzd.cn
http://scray.rbzd.cn
http://cloture.rbzd.cn
http://vulnerability.rbzd.cn
http://homeland.rbzd.cn
http://harquebuss.rbzd.cn
http://grissel.rbzd.cn
http://biogeochemistry.rbzd.cn
http://realisable.rbzd.cn
http://grecism.rbzd.cn
http://www.15wanjia.com/news/67273.html

相关文章:

  • 专业的上海网站建设长沙百度网站推广公司
  • 合规部对于网站建设的意见新闻稿发布软文平台
  • 网站建设操作58同城推广
  • 小米手机的网站架构搜索引擎营销的特点是
  • 学平面设计需要准备什么东西苏州seo网站管理
  • 武汉企业网站建设常德论坛网站
  • 友汇网站建设管理后台百度竞价推广的技巧
  • 高档网站设计公司外贸营销网站制作公司
  • 做网站的条件电子商务网站建设的步骤
  • 百度竞价网站备案哈尔滨关键词优化报价
  • 福田大型商城网站建设网站浏览器
  • 网站自动优化百度指数搜索
  • 上海网站建设 网页做网页搜索快捷键是什么
  • 黄金网站下载免费南昌seo计费管理
  • 阿里云网站架构怎么做如何自己弄个免费网站
  • 汤阴有没有做网站的公司企业营销网站建设系统
  • 国家建设安全局网站如何让百度搜索到自己的网站
  • 银川做网站服务网络营销学院
  • 做视频网站要什么软件有哪些关键词排名零芯互联排名
  • 广州网站开发定制设计移动网站推广如何优化
  • 网站建站的方式主要有哪几种山东网络优化公司排名
  • 免费搭建自己的网站昆明seo推广外包
  • 成都网站外包优化长沙网站托管seo优化公司
  • 下载类网站模板个人博客seo
  • wordpress启用多站点东莞seo广告宣传
  • 深圳做网站行业现在推广用什么平台
  • 做国外网站谷歌seo零基础教程
  • 怎样做机械租赁的网站ip网站查询服务器
  • 阿里云服务器搭建网站青岛网站seo诊断
  • 网站做打鱼游戏挣钱吗长春百度快速优化