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:全英文的,慎入

相关文章
|
3天前
|
JavaScript
vue页面加载时同时请求两个接口
vue页面加载时同时请求两个接口
|
3天前
|
JavaScript
vue里样式不起作用的方法,可以通过deep穿透的方式
vue里样式不起作用的方法,可以通过deep穿透的方式
12 0
|
3天前
|
移动开发 JavaScript 应用服务中间件
vue打包部署问题
Vue项目`vue.config.js`中,`publicPath`设定为&quot;/h5/party/pc/&quot;,在线环境基于打包后的`dist`目录,而非Linux的`/root`。Nginx代理配置位于`/usr/local/nginx/nginx-1.13.7/conf`,包含两个相关配置图。
vue打包部署问题
|
3天前
|
JavaScript 前端开发
iconfont 图标在vue里的使用
iconfont 图标在vue里的使用
15 0
|
3天前
|
JavaScript
vue打印v-model 的值
vue打印v-model 的值
|
3天前
|
JavaScript
Vue实战-组件通信
Vue实战-组件通信
5 0
|
3天前
|
JavaScript
Vue实战-将通用组件注册为全局组件
Vue实战-将通用组件注册为全局组件
5 0
|
3天前
|
JavaScript 前端开发
vue的论坛管理模块-文章评论02
vue的论坛管理模块-文章评论02
|
3天前
|
JavaScript Java
vue的论坛管理模块-文章查看-01
vue的论坛管理模块-文章查看-01
|
3天前
|
资源调度 JavaScript 前端开发
vue 项目运行过程中出现错误的问题解决
vue 项目运行过程中出现错误的问题解决