Skip to content

gaslamp


Class: SheetArtisan

Advanced Google Sheets management with caching and logging.

SheetArtisan provides efficient sheet operations with built-in caching via JunkPocket and comprehensive logging via AfterGlow.

Examples

Basic usage:

TypeScript
const artisan = new SheetArtisan({ name: "MyApp" });
const book = SpreadsheetApp.getActiveSpreadsheet();
const sheet = artisan.open(book, "DataSheet");

With logging configuration:

TypeScript
const artisan = new SheetArtisan({
  name: "DataProcessor",
  logLevel: "debug",
  enableConsole: true
});

Since

0.13.0

Constructors

Constructor

new SheetArtisan(options?): SheetArtisan

Create a new SheetArtisan instance.

Parameters

options?

SheetArtisanOptions = {}

Configuration options

Returns

SheetArtisan

New SheetArtisan instance

Gaslets

getAfterGlow()

getAfterGlow(): AfterGlow

Get the internal AfterGlow logger for advanced usage.

Returns

AfterGlow

The logger instance used by this SheetArtisan

Example

TypeScript
const artisan = new SheetArtisan();
const logger = artisan.getAfterGlow();
const logMap = logger.toMap();
const logDf = new DataFrame().fromMap(logMap);
console.log(logDf.toTableString());

Deprecated

Will be deprecated in a future version.


getJunkPocket()

getJunkPocket(): JunkPocket\<Sheet>

Get the internal JunkPocket cache for advanced usage.

Returns

JunkPocket\<Sheet>

The cache instance used by this SheetArtisan

Deprecated

Will be deprecated in a future version.


getFromCache()

getFromCache(name): Sheet | undefined

Retrieve a cached Sheet by name.

Parameters

name

string

Sheet name to retrieve

Returns

Sheet | undefined

Cached Sheet object or undefined if not found

Example

TypeScript
const sheet = artisan.getFromCache("DataSheet");
if (sheet) {
  console.log("Found cached sheet:", sheet.getSheetName());
}

Deprecated

Will be deprecated in a future version.


addToCache()

addToCache(sheet): void

Cache a Sheet object by its name.

The sheet name is automatically retrieved using getSheetName(). If already cached, the existing entry will be overwritten.

Parameters

sheet

Sheet

Sheet object to cache

Returns

void

Example

TypeScript
const sheet = book.getSheetByName("DataSheet");
artisan.addToCache(sheet);

Deprecated

Will be deprecated in a future version.


clearFromCache()

clearFromCache(name): void

Remove a specific sheet from cache.

Parameters

name

string

Name of sheet to remove from cache

Returns

void

Deprecated

Will be deprecated in a future version.


clearAll()

clearAll(): void

Clear all sheets from cache.

Returns

void

Deprecated

Will be deprecated in a future version.


open()

open(book, name): Sheet | null

Open existing sheet or create new one if it doesn't exist.

This method follows these steps: 1. Check cache first for performance 2. Try to get existing sheet from book 3. Create new sheet if not found 4. Cache the result for future use

Parameters

book

Spreadsheet

Spreadsheet containing the sheet

name

string

Name of sheet to open/create

Returns

Sheet | null

Sheet object or null if operation failed

Example

TypeScript
const book = SpreadsheetApp.getActiveSpreadsheet();
const sheet = artisan.open(book, "DataSheet");
if (sheet) {
  console.log("Sheet ready:", sheet.getSheetName());
}

Deprecated

Will be deprecated in a future version.


getSheetsFromBook()

getSheetsFromBook(book): Sheet[]

Load all sheets from a Spreadsheet into cache.

Parameters

book

Spreadsheet

Spreadsheet to load sheets from

Returns

Sheet[]

Array of all Sheet objects

Example

TypeScript
const book = SpreadsheetApp.getActiveSpreadsheet();
const sheets = artisan.getSheetsFromBook(book);
console.log(`Cached ${sheets.length} sheets`);

Deprecated

Will be deprecated in a future version.

Other

defaultName

readonly static defaultName: "SheetArtisan" = "SheetArtisan"

Default name for SheetArtisan instances