VUE 之 Jspreadsheet CE电子表格的使用步骤

简介: VUE 之 Jspreadsheet CE电子表格的使用步骤

步骤:
下载

 npm install jexcel
 或
 npm install jspreadsheet-ce

组件引入

import jexcel from 'jexcel'
import 'jexcel/dist/jexcel.css'
或
import jexcel from 'jspreadsheet-ce'
import 'jspreadsheet-ce/dist/jexcel.css'

定义容器

<div>
 <div class="deploy">
     <span>配置列:</span>
     <el-checkbox v-model="checked" @change="checkedChange">宽上下</el-checkbox>
     <el-checkbox v-model="checkeds" @change="checkedChanges">高左右</el-checkbox>
   </div>
   <div id="app" ref="spreadsheet" />
 </div>

定义配置项

data() {
    return {
        options: {
        data: Arr,
        allowToolbar: false,
        minDimensions: [10, 30],
        tableOverflow: true,
        // lazyLoading: true,
        tableWidth: '1678px',
        tableHeight: '560px',
        freezeColumns: 3,
        columns: [
          { type: 'text', title: 'xx(mm)', width: '150px' },
          { type: 'text', title: 'xx(mm)', width: '150px' },
          { type: 'hidden', title: 'xx(mm)', width: '150px' },
          { type: 'hidden', title: 'xx(mm)', width: '150px' },
          { type: 'text', title: 'xx(片)', width: '150px' },
          { type: 'text', title: 'xx(元/㎡)', width: '150px' },
          { type: 'text', title: 'xx', width: '150px' },
          { type: 'text', title: 'xx', width: '170px' },
          { type: 'text', title: 'xx', width: '150px' },
          { type: 'text', title: 'xx', width: '150px' },
          { type: 'text', title: 'xx(㎡)', width: '150px' },
          { type: 'text', title: 'xx(㎡)', width: '150px' }
        ],
        // rowResize: true,
        // columnDrag: true,
        // allowComments: true,
        contextMenu: function(obj, x, y, e) {
          console.log(`----`, obj.options)
          var items = []

          if (y == null) {
          } else {
            // Insert new row
            if (obj.options.allowInsertRow == true) {
              items.push({
                title: '在此前插入行',
                onclick: function() {
                  obj.insertRow(1, parseInt(y), 1)
                }
              })

              items.push({
                title: '在此后插入行',
                onclick: function() {
                  obj.insertRow(1, parseInt(y))
                }
              })
            }

            if (obj.options.allowDeleteRow == true) {
              items.push({
                title: '删除选中行',
                onclick: function() {
                  obj.deleteRow(obj.getSelectedRows().length ? undefined : parseInt(y))
                }
              })
            }
          }
          // Line
          items.push({ type: 'line' })
          // About
          if (obj.options.about) {
            items.push({
              title: '关于',
              onclick: function() {
                alert(obj.options.about)
              }
            })
          }

          return items
        }
      }
}
}

js实例化表格并渲染之容器中

mounted() {
    const spreadsheet = jexcel(this.$refs.spreadsheet, options)
      Object.assign(this, { spreadsheet })
      spreadsheet.refresh()
}

来看效果:
在这里插入图片描述

此表格就是web版excel功能非常强大且变态,感兴趣的可以尝试一下;
官方apiJspreadsheet CE
ps:全英文的,慎入

相关文章
|
2天前
|
JavaScript
|
4天前
|
JavaScript
【vue】el-dialog 内的tinymce弹窗被遮挡的解决办法 及 tinymce打开弹出菜单后直接关闭对话组件,导致该弹出菜单残留
【vue】el-dialog 内的tinymce弹窗被遮挡的解决办法 及 tinymce打开弹出菜单后直接关闭对话组件,导致该弹出菜单残留
16 6
|
1天前
|
存储 缓存 JavaScript
vue代码优化方案
【7月更文挑战第13天】 **Vue.js 优化要点:** 分解大组件以提高复用性和加载速度;利用计算属性与侦听器优化数据处理;使用Object.freeze()减少响应式数据;借助Vuex或Composition API管理状态;实现虚拟滚动和无限加载提升长列表性能;路由懒加载减少初始加载时间;用Vue DevTools检测性能瓶颈;定期代码审查与重构;应用缓存策略;遵循最佳实践与团队规范,提升应用整体质量。
10 2
|
4天前
|
JavaScript 前端开发
【vue】 el-table解决分页不能筛选全部数据的问题
【vue】 el-table解决分页不能筛选全部数据的问题
15 4
|
4天前
|
JavaScript
【vue】 vue2 监听滚动条滚动事件
【vue】 vue2 监听滚动条滚动事件
10 1
|
4天前
|
JavaScript 定位技术
【天地图】vue 天地图 T is not defined
【天地图】vue 天地图 T is not defined
15 1
|
4天前
|
JavaScript 前端开发
【vue】 Tinymce 数据 回显问题 | 第一次正常回显后面,显示空白bug不能编辑
【vue】 Tinymce 数据 回显问题 | 第一次正常回显后面,显示空白bug不能编辑
11 0
|
4天前
|
JavaScript 前端开发 数据安全/隐私保护
【vue】自定义指令实现 复制、长按、水印 功能
【vue】自定义指令实现 复制、长按、水印 功能
9 0
|
4天前
|
JavaScript
【vue】图片懒加载 vue-lazyload 使用
【vue】图片懒加载 vue-lazyload 使用
8 0
|
4天前
|
JavaScript
【vue】 vue如何根据不同路由地址更改页面的标题
【vue】 vue如何根据不同路由地址更改页面的标题
5 0

相关实验场景

更多