类似于Excel功能(jExcel插件)

image.png
<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>

<script src="https://bossanova.uk/jexcel/v3/jexcel.js"></script>
<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jexcel/v3/jexcel.css" type="text/css" />
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>

<input type="button" value="Add new row" onclick="vm.insertRow()" />

<script>
  var options = {
    data:[[]],
    minDimensions:[10,10],
  }

  var vm = new Vue({
    el: '#spreadsheet',
    mounted: function() {
      let spreadsheet = jexcel(this.$el, options);
      Object.assign(this, spreadsheet);
    }
  });
</script>

image.png
<html>
<script src="https://bossanova.uk/jexcel/v3/jexcel.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jexcel/v3/jexcel.css" type="text/css" />

<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>

<script>
  var data = [
    ['Jazz', 'Honda', '2019-02-12', '', true, '$ 2.000,00', '#777700'],
    ['Civic', 'Honda', '2018-07-11', '', true, '$ 4.000,01', '#007777'],
  ];

  jexcel(document.getElementById('spreadsheet'), {
    data:data,
    columns: [
      { type: 'text', title:'Car', width:120 },
      { type: 'dropdown', title:'Make', width:200, source:[ "Alfa Romeo", "Audi", "Bmw" ] },
      { type: 'calendar', title:'Available', width:200 },
      { type: 'image', title:'Photo', width:120 },
      { type: 'checkbox', title:'Stock', width:80 },
      { type: 'numeric', title:'Price', width:100, mask:'$ #.##,00', decimal:',' },
      { type: 'color', width:100, render:'square', }
    ]
  });
</script>
</html>

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容