欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue如何實(shí)現(xiàn)在線(xiàn)編輯excel

 更新時(shí)間:2023年10月24日 08:45:29   作者:不會(huì)么么噠  
這篇文章主要介紹了vue如何實(shí)現(xiàn)在線(xiàn)編輯excel問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

vue實(shí)現(xiàn)在線(xiàn)編輯excel

不支持ie  支持edge  需要ie請(qǐng)換方法 

vue不再贅述

安裝x-data-spreadsheet

npm install x-data-spreadsheet
<template>
		<div id="x-spreadsheet-demo"></div>
</template>
<script>
	import Spreadsheet from 'x-data-spreadsheet';
	import zhCN from 'x-data-spreadsheet/dist/locale/zh-cn';
  export default {
    data() {
      return {
      	options:{
  	mode: 'edit',
  showToolbar: true,
  showGrid: true,
  showContextmenu: true,
  view: {
  	/*寬高,因?yàn)槲沂亲远x的所以-----*/
  	/*height: () => document.documentElement.clientHeight - 300,
  	width: () => document.documentElement.clientWidth - 300,*/
    height: () => document.documentElement.clientHeight - 64,
    width: () => document.documentElement.clientWidth - 150,
  },
  formats: [],
  fonts: [],
  formula: [],
  row: {
    len: 100,
    height: 25,
  },
  
  col: {
    len: 26,
    width: 100,
    indexWidth: 60,
    minWidth: 60,
  },
  /*freeze: 'C3',*/
  style: {
    bgcolor: '#ffffff',
    align: 'left',
    valign: 'middle',
    textwrap: false,
    textDecoration: 'normal',
    strikethrough: false,
    color: '#0a0a0a',
    font: {
      name: 'Helvetica',
      size: 10,
      bold: false,
      italic: false,
    },
  },
},
/*數(shù)組*/
optionss:[{
	name:'aaaa',
          /*freeze: 'C3',*/
          styles: [
            {
            	/*小框背景色*/
              bgcolor: '#f4f5f8',
              textwrap: true,
              color: '#900b09',
              border: {
                top: ['thin', '#0366d6'],
                bottom: ['thin', '#0366d6'],
                right: ['thin', '#0366d6'],
                left: ['thin', '#0366d6'],
              },
            },{
            	/*小框背景色*/
              bgcolor: '#000000',
              textwrap: true,
              color: '#000000',
              border: {
                top: ['thin', '#000000'],
                bottom: ['thin', '#000000'],
                right: ['thin', '#000000'],
                left: ['thin', '#000000'],
              },
            },
          ],
          /*合并單元格*/
          merges: [
            'C3:E4',
          ],
          rows: {
          	/*第1行*/
            1: {
              cells: {
              	/*第0列 2列*/
                0: { text: 'testingtesttestetst' },
                2: { text: 'testing' },
              },
            },
            2: {
              cells: {
                0: { text: 'render', style: 0 },
                1: { text: 'Hello' },
                2: { text: 'haha', merge: [1, 2] },
              }
            },
            8: {
              cells: {
                8: { text: 'border test', style: 0 },
              }
            }
          },
        },{
	name:'aaaa',
          /*freeze: 'C3',*/
          styles: [
            {
            	/*小框背景色*/
              bgcolor: '#f4f5f8',
              textwrap: true,
              color: '#900b09',
              border: {
                top: ['thin', '#0366d6'],
                bottom: ['thin', '#0366d6'],
                right: ['thin', '#0366d6'],
                left: ['thin', '#0366d6'],
              },
            },{
            	/*小框背景色*/
              bgcolor: '#000000',
              textwrap: true,
              color: '#000000',
              border: {
                top: ['thin', '#000000'],
                bottom: ['thin', '#000000'],
                right: ['thin', '#000000'],
                left: ['thin', '#000000'],
              },
            },
          ],
          /*合并單元格*/
          merges: [
            'C3:E4',
          ],
          rows: {
          	/*第1行*/
            1: {
              cells: {
              	/*第0列 2列*/
                0: { text: 'testingtesttestetst' },
                2: { text: 'testing' },
              },
            },
            2: {
              cells: {
                0: { text: 'render', style: 0 },
                1: { text: 'Hello' },
                2: { text: 'haha', merge: [1, 2] },
              }
            },
            8: {
              cells: {
                8: { text: 'border test', style: 0 },
              }
            }
          },
        }]
      }
    },
      methods: {
      },
    mounted:function(){
    	/*中文*/
    	Spreadsheet.locale('zh-cn', zhCN);
		new Spreadsheet('#x-spreadsheet-demo', this.options).loadData(this.optionss).change((data) => {
    console.log(data)
  });
  }
   }
</script>
 
<style>
</style>

vue導(dǎo)出excel模板

1、首先需要導(dǎo)入第三方插件xlsx(最好是指定版本,要不然容易報(bào)錯(cuò))

npm install --save xlsx@0.17.0

后續(xù)可能還會(huì)用到導(dǎo)入導(dǎo)出,也需要安裝第三方插件

npm install --save file-saver@2.0.5

2、哪個(gè)頁(yè)面需要下載excel模板就到哪里導(dǎo)入

import XLSX from "xlsx"

3、給下載模板按鈕綁定事件

<el-button @click="downloadExcel">嗨嗨嗨</el-button>

4、下載模板執(zhí)行內(nèi)容

downloadExcel() {
            let excelData = [
                [ '姓名', '電話(huà)', '生日', 'xx', "xx",  "……"]//這里是表頭數(shù)據(jù)
            ]
            let ws = XLSX.utils.aoa_to_sheet(excelData)
            let wb = XLSX.utils.book_new()
            XLSX.utils.book_append_sheet(wb, ws, '工作簿名稱(chēng)')
            XLSX.writeFile(wb, '保存的文件名.xlsx')
        }

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue組件之間的通信方式詳細(xì)講解

    Vue組件之間的通信方式詳細(xì)講解

    對(duì)于vue來(lái)說(shuō),組件之間的消息傳遞是非常重要的,用vue可以是要組件復(fù)用的,而組件實(shí)例的作用域是相互獨(dú)立,這意味著不同組件之間的數(shù)據(jù)無(wú)法互相引用,一般來(lái)說(shuō),組件之間可以有幾種關(guān)系,下面是我對(duì)組件之間消息傳遞的常用方式的總結(jié)
    2022-08-08
  • VuePress 側(cè)邊欄的具體使用

    VuePress 側(cè)邊欄的具體使用

    本文主要介紹了VuePress 側(cè)邊欄的具體使用,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-06-06
  • vue3 elementPlus 表格實(shí)現(xiàn)行列拖拽及列檢索功能(完整代碼)

    vue3 elementPlus 表格實(shí)現(xiàn)行列拖拽及列檢索功能(完整代碼)

    本文通過(guò)實(shí)例代碼給大家介紹vue3 elementPlus 表格實(shí)現(xiàn)行列拖拽及列檢索功能,代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2023-10-10
  • Vue 實(shí)現(xiàn)html中根據(jù)類(lèi)型顯示內(nèi)容

    Vue 實(shí)現(xiàn)html中根據(jù)類(lèi)型顯示內(nèi)容

    今天小編大家分享一篇Vue 實(shí)現(xiàn)html中根據(jù)類(lèi)型顯示內(nèi)容,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-10-10
  • vue.js入門(mén)教程之基礎(chǔ)語(yǔ)法小結(jié)

    vue.js入門(mén)教程之基礎(chǔ)語(yǔ)法小結(jié)

    這篇文章我們將學(xué)習(xí)vue.js的基礎(chǔ)語(yǔ)法,對(duì)于大家學(xué)習(xí)vue.js具有一定的參考借鑒價(jià)值,有需要的朋友們下面來(lái)一起看看。
    2016-09-09
  • vue輪播圖插件vue-awesome-swiper

    vue輪播圖插件vue-awesome-swiper

    這篇文章主要為大家詳細(xì)介紹了vue輪播圖插件vue-awesome-swiper,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-11-11
  • vue3中如何使用vue-types

    vue3中如何使用vue-types

    vue-types 在 Vue 3 中的使用主要適用于希望進(jìn)行更細(xì)致的 prop 驗(yàn)證的場(chǎng)景,尤其是在 JavaScript 項(xiàng)目中,這篇文章給大家介紹vue3中如何使用vue-types,感興趣的朋友跟隨小編一起看看吧
    2024-04-04
  • vue中json格式化顯示數(shù)據(jù)(vue-json-viewer)

    vue中json格式化顯示數(shù)據(jù)(vue-json-viewer)

    這篇文章主要給大家介紹了關(guān)于vue中json格式化顯示數(shù)據(jù)(vue-json-viewer)的相關(guān)資料,Vue-json-viewer是一個(gè)Vue組件,用于在Vue應(yīng)用中顯示JSON數(shù)據(jù)的可視化工具,需要的朋友可以參考下
    2024-05-05
  • vue3.x?的shallowReactive?與?shallowRef?使用場(chǎng)景分析

    vue3.x?的shallowReactive?與?shallowRef?使用場(chǎng)景分析

    在Vue3.x中,`shallowReactive`和`shallowRef`是用于創(chuàng)建淺層響應(yīng)式數(shù)據(jù)的API,它們與`reactive`和`ref`類(lèi)似,本文介紹vue3.x??shallowReactive?與?shallowRef的使用場(chǎng)景,感興趣的朋友一起看看吧
    2025-02-02
  • VUE插件vue-treeselect的使用及說(shuō)明

    VUE插件vue-treeselect的使用及說(shuō)明

    這篇文章主要介紹了VUE插件vue-treeselect的使用及說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。
    2023-07-07

最新評(píng)論