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

@dtrlanz/sheetable

v0.1.0

Published

Utility for reading & writing tables in Sheets using Google Apps Script

Downloads

4

Readme

Sheetable

A utility for reading & writing tables in spreadsheets using Google Apps Script


Install

npm install @dtrlanz/sheetable

Usage

The following examples assume you are building your project with a bundler that allows you to import modules (e.g., @dtrlanz/gas-bundler).

For an example setup, see the server-side code, client-side HTML, and build script of the included test app.

Server-side code

Import SpreadsheetServer and add the following top-level function to your code:

import { SpreadsheetServer } from "@dtrlanz/sheetable";

function processSpreadsheetRequest(req) {
    return new SpreadsheetServer().processRequest(req);
}

If you want to limit client access to a specific spreadsheet, pass that to the SpreadsheetServer constructor:

const spreadsheet = SpreadsheetApp.openByUrl(/* spreadsheet url */);

function processSpreadsheetRequest(req) {
    return new SpreadsheetServer(spreadsheet).processRequest(req);
}

Note: As always, if you are using a bundler that performs tree-shaking, you will need to ensure your top-level functions are not eliminated. You can do this by assigning to globalThis:

globalThis.processSpreadsheetRequest = processSpreadsheetRequest;

Client-side code

Import Table and create a class that defines the records in your table. You can then create new table using Table.create() or open a table from an existing spreadsheet using Table.open().

import { Table } from "@dtrlanz/sheetable";

class Person {
    firstName = "";
    lastName = "";
    dob = new Date(0);
}

const people = Table.create(Person);

For further customization, you will probably want to import some decorators as well:

import { Table, title, index } from "@dtrlanz/sheetable";

class Person {
    @index
    @title("ID")
    id = 0;

    @title("First name")
    firstName = "";

    @title("Last name")
    lastName = "";

    @title("Date of birth")
    dob = new Date(0);
}

const people = Table.create(Person);

Attribution & Disclaimer

Google and Google Sheets are trademarks of Google LLC. This project is not endorsed by or affiliated with Google in any way.

License

Sheetable is released under the MIT license.