nuxt-google-sheets-parser

1.3.4 • Public • Published

nuxt-google-sheets-parser

public google sheets parser for nuxt.js

Setup

  1. Add nuxt-google-sheets-parser dependency to your project
yarn add nuxt-google-sheets-parser
# or npm install nuxt-google-sheets-parser
  1. Add nuxt-google-sheets-parser to the modules section of nuxt.config.js
{
  modules: [
    'nuxt-google-sheets-parser'
  ]
}

Usage Example

  • In your page or components on nuxt.js
// ...
export default {
  // ...
  methods: {
    parseSheet (sheetId, sheetInfo = { sheetId: null, sheetName: null }) {
      return this.$gsparser.parse(sheetId, sheetInfo)
    }
  },
  async mounted () {
    // see: https://docs.google.com/spreadsheets/d/10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps
    const sheetId = '10WDbAPAY7Xl5DT36VuMheTPTTpqx9x0C5sDCnh4BGps'

    const data1 = await this.parseSheet(sheetId)
    console.log(data1) // [{"a":1,"b":2,"c":3},{"a":4,"b":5,"c":6},{"a":7,"b":8,"c":9}]

    const data2 = await this.parseSheet(sheetId, 'Sheet2')
    console.log(data2) // [{"a":10,"b":20,"c":30},{"a":40,"b":50,"c":60},{"a":70,"b":80,"c":90}]

    // since v1.3.0
    const data3 = await this.parseSheet(sheetId, { sheetId: 1839148703 }) // or pass { sheetName: 'Sheet1' }
    console.log(data3) // [{"a":1,"b":2,"c":3},{"a":4,"b":5,"c":6},{"a":7,"b":8,"c":9}]

    const data4 = await this.parseSheet(sheetId, { sheetId: 784337977 }) // or pass { sheetName: 'Sheet2' }
    console.log(data4) // [{"a":10,"b":20,"c":30},{"a":40,"b":50,"c":60},{"a":70,"b":80,"c":90}]
  },
  // ...
}

License

MIT License

Copyright (c) Jihwan Oh

Package Sidebar

Install

npm i nuxt-google-sheets-parser

Weekly Downloads

5

Version

1.3.4

License

MIT

Unpacked Size

5.39 kB

Total Files

5

Last publish

Collaborators

  • fureweb