Skip to content

schlunsen/nuxt-spreadsheet

Repository files navigation

nuxt-spreadsheet

npm version npm downloads Dependencies Standard JS

A nuxt module for x-data-spreadsheet

Nuxt module for https://github.com/myliang/x-spreadsheet

Setup

  1. Add nuxt-spreadsheet dependency to your project
npm install nuxt-spreadsheet
  1. Add nuxt-spreadsheet to the modules section of nuxt.config.js
{
  modules: [
    'nuxt-spreadsheet',
  ]
}

Usage

Add the spreadsheet to your page

<template>
  <div>
      <spreadsheet :options="options" :data="data" :onChange="onChange" ref="spreadsheet"/>
  </div>
</template>

<script>
export default {
  data() {
    return {
      spreadsheet: null,
      // If other options needed
      options: {
        ...
      },
      // Initial data for spreadsheet
      data: {
        ...
      }
    }
  },
  mounted() {
    this.spreadsheet = this.$refs.spreadsheet.spreadsheet
  },
  methods: {
    onChange: function(data) {

    }
  }

}
</script>

The x-data-spreadsheet spreadsheet object can be found via refs: this.$refs.spreadsheet.spreadsheet

See https://github.com/myliang/x-spreadsheet/blob/master/docs/index.html for data format

Options

// default options
{
  showToolbar: true,
  showGrid: true,
  showContextmenu: true,
  view: {
    height: () => document.documentElement.clientHeight,
    width: () => document.documentElement.clientWidth,
  },
  row: {
    len: 100,
    height: 25,
  },
  col: {
    len: 26,
    width: 100,
    indexWidth: 60,
    minWidth: 60,
  },
  style: {
    bgcolor: '#ffffff',
    align: 'left',
    valign: 'middle',
    textwrap: false,
    strike: false,
    underline: false,
    color: '#0a0a0a',
    font: {
      name: 'Helvetica',
      size: 10,
      bold: false,
      italic: false,
    },
  },
}

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using npm run dev

License

MIT License

Copyright (c) Rasmus Schlünsen