npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simpol-google-sheet

v0.1.4

Published

simpol-google-sheet is an angular library for retrieving, updating data from google spread sheet.

Downloads

3

Readme

About

simpol-google-sheet is an angular library for retrieving, updating data from google spread sheet.

Getting started

npm install simpol-google-sheet

Usage

Import GSheetModule

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { GSheetModule } from 'simpol-google-sheet';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    GSheetModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Edit package.json and add this

package.json

  "browser": {
    "path": false,
    "os": false,
    "child_process": false,
    "fs": false
  },

Edit tsconfig and add this inside the compilerOptions

tsconfig.json
"compilerOptions": {
    ...
    "paths": {
        "crypto": [
            "node_modules/crypto-browserify"
            ],
        "stream": [
            "node_modules/stream-browserify"
            ]
        }
    ...

Put this to your index.html tag. It will get rid of errors related to accessing the global as it substitutes it with the window.

index.html

<head>
  <script>
    if (global === undefined) {
        var global = window;
    }
</script>
...
</head>

Add the following imports in your polyfills

src/polyfills.ts
import * as process from 'process';
(window as any).process = process;
import { Buffer } from 'buffer';
(window as any).Buffer = Buffer;

Add google-sheet component in the html

app.component.html
<google-sheet></google-sheet>

Add GoogleSheetService in the app component and provide credentials

app.component.ts

import { Component, OnInit } from '@angular/core';
import { GoogleSheetService } from 'simpol-google-sheet';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {

  constructor(private googleSheet: GoogleSheetService){
  }

  ngOnInit(): void{
        this.googleSheet.init({
          credentials: {
            client_email: '<--- GOOGLE EMAIL --->',
            private_key: '<--- GOOGLE PRIVATE KEY --->'
          },
          sheetId: '<--- GOOGLE SHEET ID --->'
        });
  }
}

Inputs of google-sheet component

Input | Type | Default | Description ---------------- | ------------ | ----------- | -------------------------------------------------------- editable | boolean | false | When set to true, allows cell editing and updates google spread sheet data almost in realtime

Outputs of google-sheet component

Output | Description ---------------- | -------------------------------------------------------- (itemClick) | Emits row index and row data when row is clicked

Methods of GoogleSheetService

Name | Parameter & Types | Description ----------------------------------------------- | ----------------------------------------- | ----------------------- getSheetByIndex(index) | index: number | Get sheet by index getSheetByTitle(title) | title: string | Get sheet by title loadRows(sheetIndex) | sheetIndex: number, row: any | Load rows by sheet index addRow(sheet, row) | sheet: number or string, row: any | Add single row to the sheet addRows(sheet, [ ...rows ]) | sheet: number or string, [ ...rows ] | Adds multiple rows deleteRow(sheet, rowIndex ) | sheet: number or string, rowIndex: number | Delete row updateRowByField(sheet, rowIndex, fieldName, value) | sheet: number or string, rowIndex: number, fieldName: string, value: any | Update cell by using fieldname addSheet(title) | title: string | Add new sheet to the document setTitle(title) | title: string | Set title to the document getData$() |none | get data as observable returns headers and rows of the sheet