メインコンテンツにスキップ

Config-Driven-Apps-Script-Framework

A modular, config-based framework to streamline Google Sheets development with Apps Script. Define layout, validation, formatting, and automation logic in one place using a central SHEETCONFIG and the SmartSheet utility class.

AI Summary

Config-Driven Apps Script Framework (CDAS)

A Google Apps Script library that lets you declare Google Sheets layout, validation, and automation in a single SHEETCONFIG object and operate them via a SmartSheet class.

Target Users

Intermediate-to-advanced GAS developers maintaining multi-sheet business spreadsheets.

Problems Solved

Sheet structure, validation, and onEdit logic are scattered across scripts, making maintenance difficult.

Tags

Main Features

1
Centralized Configuration

Columns, named ranges, validation, formatting and edit rules are defined in one SHEETCONFIG object, eliminating scattered code.

2
SmartSheet Class

Provides high-level APIs such as row objects, calculated columns, and named-range access by semantic names.

3
Declarative Validation & Formatting

Create DataValidation and conditional formatting rules dynamically via functions and apply them automatically.

4
Rule-Based onEdit

Manage edit events declaratively by pairing conditions and handlers in onEditRules.

5
Calculated Columns & Named Ranges

Define inline formulas or functions for automatic calculations and optionally lock the resulting cells.

Usage Examples

Read a row with minimal setup

/**
 * Define a minimal SHEETCONFIG (config.gs)
 */
const SHEETCONFIG = {
  Employees: {
    layout: {
      columns: {
        A: { name: 'name', type: 'string' },
        B: { name: 'age',  type: 'number' }
      }
    }
  }
};

/**
 * Test function to read row data (Code.gs)
 */
function testReadRow() {
  // Get the target sheet
  const sheet = SpreadsheetApp.getActive()
    .getSheetByName('Employees');

  // Create SmartSheet instance
  const smart = new SmartSheet(sheet);

  // Fetch row 5 as an object, e.g. {name: 'Alice', age: 30}
  const row = smart.getRowData(5);
  Logger.log(row);
}

Copy this snippet into your Apps Script project and prepare an "Employees" sheet—SmartSheet will fetch data by column names as shown.