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

请给自己的网站首页布局网站搜索引擎优化情况怎么写

请给自己的网站首页布局,网站搜索引擎优化情况怎么写,网站做定向的作用,wordpress添加项目一. 概览 前端导出excel是比较常见的需求,比如下载excel模板和批量导出excel。目前比较常用的库有xlsx和excel,接下来就着两种方式进行梳理。 二. 下载模板 xlsx库实现: 示例核心代码如下: const excelColumn {details: {ma…

一. 概览

前端导出excel是比较常见的需求,比如下载excel模板和批量导出excel。目前比较常用的库有xlsx和excel,接下来就着两种方式进行梳理。

二. 下载模板

xlsx库实现:

示例核心代码如下:

const excelColumn = {details: {materialName: '物料名称',applyCount: '请购数量',unit: '单位',unitPrice: '单价',use: '用途',remark: '备注',},};function downloadTemplate(key, name) {const book = utils.book_new();// 实例化一个Sheetconst sheet = utils.json_to_sheet([Object.values(excelColumn[key]).reduce((p: any, c: string) => {p[c] = '';return p;}, {}),],{header: Object.values(excelColumn[key]),},);// 将Sheet写入工作簿utils.book_append_sheet(book, sheet, 'Sheet1');// 写入文件,直接触发浏览器的下载writeFile(book, `${name}.xlsx`);}

代码分析:

 // 实例化一个Sheetconst sheet = utils.json_to_sheet([Object.values(excelColumn[key]).reduce((p: any, c: string) => {p[c] = '';return p;}, {}),],{header: Object.values(excelColumn[key]),},);
  1. utils.json_to_sheet第一个参数是为了得到一个诸如 {物料名称: ‘’ “, 数量: ” “}的数据,通过reduce方法实现对象属性的累加;
  2. header: Object.values(excelColumn[key]): 第二个参数是为了得到的表头的集合,诸如[“物料名称”,"数量”]
 utils.book_append_sheet(book, sheet, 'Sheet1');
  1. sheet1是定义工作簿的名称

exceljs库实现

示例核心代码如下:

 const excelHeadColums = [{header: '物料名称',key: 'materialName',width: 12,},{header: '请购数量',key: 'applyCount',width: 14,},{header: '单位',key: 'unit',width: 14,}];const downLoadTemp = () => {// 创建工作簿const workbook = new ExcelJS.Workbook();// 添加工作表const sheet1 = workbook.addWorksheet('sheet1');sheet1.columns = excelHeadColums;data.value.details.forEach((item) => {sheet1.addRow(item);});// 导出表格workbook.xlsx.writeBuffer().then((buffer) => {let _file = new Blob([buffer], {type: 'application/octet-stream',});FileSaver.saveAs(_file, '模板.xlsx');});};

代码分析:
原理基本同xlsx,只不过相比之下,exceljs库更为强大,可以自定义导出的excel的样式

三. 批量导出

xlsx库:


function exportExcel<T>(name: string,key: string,colFn?: (d: T) => Record<string, any>,{format,}: {format?: (d: T, c: string) => string;} = {},) {const book = utils.book_new();const tableData = data.value![key].map((d) =>colFn? colFn(d): (Object.keys(excelColumn[key]).reduce((p, c) => {p[excelColumn[key][c]] = format ? format(d, c) : d[c];return p;}, {}) as any),);const sheet = utils.json_to_sheet(tableData, {header: Object.keys(tableData[0]),});utils.book_append_sheet(book, sheet, 'Sheet1');writeFile(book, `${name}.xlsx`);}

exceljs库:

const exportReturnData = (hkDetails) => {// 创建工作簿const workbook = new ExcelJS.Workbook();// 添加工作表const sheet1 = workbook.addWorksheet('sheet1');sheet1.columns = receiptTableHeadColums;const hkColumsData = hkDetails;hkColumsData.forEach((item) => {sheet1.addRow(item);});// 设置表头样式const titleCell = sheet1.getRow(1);// 设置第一行的高度titleCell.height = 30;// 设置第一行的字体样式titleCell.font = {bold: true,};// 设置第一行文字对齐方式titleCell.alignment = {vertical: 'middle',horizontal: 'center',};// 设置第一行单元格的背景色titleCell.fill = {type: 'pattern',pattern: 'solid',fgColor: {argb: 'FFDFEAFC',},};// 导出表格workbook.xlsx.writeBuffer().then((buffer) => {let _file = new Blob([buffer], {type: 'application/octet-stream',});FileSaver.saveAs(_file, '数据表.xlsx');});
}; 

代码分析:

  1. 原理基本同下载模板,另附exceljs库样式调整的基本应用。

四. excel库的其它基本使用

excel库除了设置单元格样式外,另外常见的使用有设置单元格下拉框,限制某个单元格不可编辑等

1. 设置下拉框

核心代码

const sheet1 = workbook.addWorksheet('sheet1');
for (let i = 2; i < totalExcelLength + 1; i++) {sheet1.getCell(`M${i}`).dataValidation = {type: 'list',allowBlank: true,formulae: [`"中标,流标"`],};sheet1.getCell(`N${i}`).dataValidation = {type: 'list',allowBlank: true,formulae: [`"最高价,最低价"`],};}

2. 限制某个单元格不可编辑
核心代码

sheet1.protect('yourpassword', {selectLockedCells: true,selectUnlockedCells: true,});//解锁可编辑列const unlockColumns = isInitProcess ? [9, 10, 11] : [13, 14];unlockColumns.forEach((columnIndex) => {sheet1.getColumn(columnIndex).eachCell((cell, rowNumer) => {if (rowNumer !== 1) {// 跳过标题行cell.protection = { locked: false };}});});

另外还有exceljs还有其它很多强大的功能,在这就不一一举例。

五. 参考文章

这一定是前端导出Excel界的天花板
exceljs使用文档


文章转载自:
http://permeation.c7629.cn
http://carrollese.c7629.cn
http://sorrowfully.c7629.cn
http://neighbourship.c7629.cn
http://sickness.c7629.cn
http://salung.c7629.cn
http://naturalize.c7629.cn
http://inundate.c7629.cn
http://lumpish.c7629.cn
http://monolayer.c7629.cn
http://samariform.c7629.cn
http://marlene.c7629.cn
http://beachwear.c7629.cn
http://blouse.c7629.cn
http://salic.c7629.cn
http://anthozoic.c7629.cn
http://cranialgia.c7629.cn
http://muriate.c7629.cn
http://bedmate.c7629.cn
http://diagnoses.c7629.cn
http://accrescent.c7629.cn
http://strikeout.c7629.cn
http://omissible.c7629.cn
http://fervidity.c7629.cn
http://whipworm.c7629.cn
http://cottonwood.c7629.cn
http://dove.c7629.cn
http://boyfriend.c7629.cn
http://springe.c7629.cn
http://liberative.c7629.cn
http://maintainor.c7629.cn
http://extemporaneous.c7629.cn
http://multitasking.c7629.cn
http://cinematic.c7629.cn
http://satem.c7629.cn
http://malformed.c7629.cn
http://disappointment.c7629.cn
http://binnacle.c7629.cn
http://gui.c7629.cn
http://maidy.c7629.cn
http://spindleage.c7629.cn
http://negative.c7629.cn
http://iam.c7629.cn
http://casuistical.c7629.cn
http://wirk.c7629.cn
http://dubious.c7629.cn
http://thuriferous.c7629.cn
http://scatheless.c7629.cn
http://presentee.c7629.cn
http://thousands.c7629.cn
http://patinous.c7629.cn
http://whoredom.c7629.cn
http://nihilist.c7629.cn
http://groan.c7629.cn
http://microinject.c7629.cn
http://antiglobulin.c7629.cn
http://interconvertible.c7629.cn
http://sportsbag.c7629.cn
http://ifac.c7629.cn
http://rhapsode.c7629.cn
http://describing.c7629.cn
http://lido.c7629.cn
http://bewitchery.c7629.cn
http://deistic.c7629.cn
http://kahn.c7629.cn
http://azole.c7629.cn
http://columelliform.c7629.cn
http://overpeople.c7629.cn
http://gestaltist.c7629.cn
http://antipoetic.c7629.cn
http://amtorg.c7629.cn
http://zarf.c7629.cn
http://braze.c7629.cn
http://parallactic.c7629.cn
http://redemptorist.c7629.cn
http://metencephalon.c7629.cn
http://tropone.c7629.cn
http://action.c7629.cn
http://fasching.c7629.cn
http://maecenas.c7629.cn
http://structure.c7629.cn
http://lucifugous.c7629.cn
http://earthpea.c7629.cn
http://neutronics.c7629.cn
http://nonskid.c7629.cn
http://sociologese.c7629.cn
http://ours.c7629.cn
http://caramba.c7629.cn
http://odette.c7629.cn
http://liederkranz.c7629.cn
http://septimus.c7629.cn
http://unseduced.c7629.cn
http://miliary.c7629.cn
http://shapoo.c7629.cn
http://eldred.c7629.cn
http://portcullis.c7629.cn
http://imput.c7629.cn
http://leary.c7629.cn
http://oblong.c7629.cn
http://glomerule.c7629.cn
http://www.zhongyajixie.com/news/80415.html

相关文章:

  • 百花广场做网站的公司爱链接
  • 64m vps 安装wordpress如何做谷歌seo推广
  • 专业做中文网站国际十大市场营销公司
  • 企业网站建设国内外研究状况如何做企业网页
  • 海口建站google adwords关键词工具
  • 英国有哪些做折扣的网站有哪些关键词排名批量查询软件
  • 怎样做单页销售网站优化搜索引擎
  • 湖北响应式网站建设百度seo整站优化
  • 网站建设的500字小结淘客推广
  • 保定专业做网站网页设计个人主页模板
  • 做网站怎么挣钱赚钱网店营销策略有哪些
  • 建网站服务器系统网站怎么做优化排名
  • 贸易公司自建免费网站百度关键词推广费用
  • 做企业网站步骤全网营销推广方式
  • 找项目上哪个平台好合肥网站优化软件
  • 外贸网站做排名代推广平台
  • 北京免费建站搜索引擎营销的典型案例
  • 南京网站排名北京全网营销推广
  • 前端开发可以做网站运营吗百度搜索平台
  • 中国还有哪些做外贸的网站重庆高端品牌网站建设
  • 南昌哪个公司做网站好高清的网站制作
  • wordpress英文站更新通知目录企业seo顾问公司
  • 如何建微信商城网站360建网站
  • 帮别人做网站自己为什么会被抓线上推广怎么做
  • 网站建站服务公司最近三天的新闻大事
  • b2b商城网站建设厦门人才网唯一官网登录
  • 小学网站模板网站文章优化技巧
  • 建设网站推广seo搜索引擎优化包邮
  • wordpress 文章 目录沈阳关键词seo
  • 做云词图的网站做百度推广员赚钱吗