=QUANTLEDGER() Custom Formulas · Google Sheets · Microsoft Excel · n8n Workflow Node

Google Sheets =QUANTLEDGER() Formulas, Excel Spill Scripts & Official n8n Node

Call all 73 deterministic GAAP, IRC Corporate Tax, 409A, DCAA, QoE & Credit engines, screen 138,000+ US OFAC/BIS/OIG sanctions, pull live SEC Form D funded startups, and filter 121,000+ DOL Form 5500 retirement plans directly inside spreadsheet cells or automated n8n pipelines — with zero setup required to test.

Live 2D Spill Array Preview

Interactive Spreadsheet Formula Bar Simulator

fx
Select any function above and click "Evaluate Spill Formula" to preview exact 2D cell output.
#AB
1Click Evaluate Spill Formula above to render the live spreadsheet spill table.

1. Google Sheets Custom Functions (=QUANTLEDGER, =QUANTLEDGER_KYB, =QUANTLEDGER_FORMD, =QUANTLEDGER_5500)

Open any Google Sheet → click Extensions → Apps Script → paste the script below and click Save. Works immediately in free 12-row preview mode with 10-minute SHA-256 cell memoization; add a RapidAPI Key from the QuantLedger sheet menu anytime to unlock 100-row Pro tables.

Download QuantLedger_GoogleSheets.gs
/**
 * QuantLedger 73-Engine GAAP, Tax, KYB, Form D & Form 5500 Custom Functions for Google Sheets
 * Version: 2.8.2 | Docs: https://quantledgerapi.github.io/google-sheets-excel-formulas-and-n8n/
 *
 * 10-SECOND INSTALL:
 *   1. In Google Sheets, click Extensions -> Apps Script, paste this file, and click Save.
 *   2. Type =QUANTLEDGER("BI-17", "NY") or =QUANTLEDGER_KYB(A2:A10) in any cell — works immediately in free preview mode!
 *   3. Optional Pro Mode (100 rows & higher quota): Reload your sheet -> QuantLedger menu -> Set RapidAPI Key
 *      (get 5 free/mo or Pro at https://rapidapi.com/quantledger/api/quantledger-73-engine-financial-and-statutory-api).
 */

const QL_RAPIDAPI_URL = 'https://quantledger-73-engine-financial-and-statutory-api.p.rapidapi.com/v1/spreadsheet/formula-eval';
const QL_RAPIDAPI_HOST = 'quantledger-73-engine-financial-and-statutory-api.p.rapidapi.com';
const QL_FREE_DEMO_URL = 'https://quantledger-ghost-kitchen-3yplwqtnha-uc.a.run.app/v1/public/spreadsheet-demo';

function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('QuantLedger')
    .addItem('Set RapidAPI Key (Unlock 100-Row Pro Mode)', 'quantledgerSetApiKey')
    .addItem('Clear Formula Cache', 'quantledgerClearCache')
    .addToUi();
}

function quantledgerSetApiKey() {
  const ui = SpreadsheetApp.getUi();
  const res = ui.prompt(
    'QuantLedger RapidAPI Key',
    'Paste your X-RapidAPI-Key from rapidapi.com/quantledger (leave blank to use free 12-row preview mode):',
    ui.ButtonSet.OK_CANCEL
  );
  if (res.getSelectedButton() === ui.Button.OK) {
    PropertiesService.getScriptProperties().setProperty('RAPIDAPI_KEY', res.getResponseText().trim());
    ui.alert('Saved! Re-enter or refresh your =QUANTLEDGER(...) formulas to apply.');
  }
}

function quantledgerClearCache() {
  CacheService.getScriptCache().removeAll(['ql_ping']);
  SpreadsheetApp.getUi().alert('Cache notice: New parameter edits automatically bypass cached cells (10-min TTL).');
}

function _qlInvokeBridge(payload) {
  const apiKey = (PropertiesService.getScriptProperties().getProperty('RAPIDAPI_KEY') || '').trim();
  const rawJson = JSON.stringify(payload);
  const digest = Utilities.computeDigest(Utilities.DigestAlgorithm.SHA_256, (apiKey ? 'PRO:' : 'DEMO:') + rawJson);
  const cacheKey = 'ql_' + digest.slice(0, 16).map(function (b) { return ('0' + (b & 0xff).toString(16)).slice(-2); }).join('');
  const cache = CacheService.getScriptCache();
  const hit = cache.get(cacheKey);
  if (hit) {
    return JSON.parse(hit);
  }
  const url = apiKey ? QL_RAPIDAPI_URL : QL_FREE_DEMO_URL;
  const headers = { 'Content-Type': 'application/json' };
  if (apiKey) {
    headers['X-RapidAPI-Key'] = apiKey;
    headers['X-RapidAPI-Host'] = QL_RAPIDAPI_HOST;
  }
  const resp = UrlFetchApp.fetch(url, {
    method: 'post',
    headers: headers,
    payload: rawJson,
    muteHttpExceptions: true,
  });
  const code = resp.getResponseCode();
  const data = JSON.parse(resp.getContentText() || '{}');
  if (code >= 400) {
    throw new Error(data.detail || data.message || ('QuantLedger HTTP ' + code));
  }
  const out = (String(payload.output_mode || '').toLowerCase().indexOf('scalar') === 0)
    ? data.scalar_value
    : (data.rows || [['No rows returned']]);
  const serialized = JSON.stringify(out);
  if (serialized.length < 95000) {
    cache.put(cacheKey, serialized, 600);
  }
  return out;
}

/**
 * Executes any of QuantLedger's 73 deterministic GAAP, IRC Tax, 409A, QoE, DCAA, CRE or Credit engines (BI-01..BI-73).
 * @param {"BI-17"} engineCode Engine code from BI-01 to BI-73 (e.g. "BI-17" ASC 842 Lease, "BI-07" DCAA Wrap, "BI-48" 409A).
 * @param {"NY"} jurisdiction 2-letter US State, DC, PR, GU, VI, AS, MP, or US.
 * @param {A2:B8} inputRange Optional 2-column [parameter_name, value] cell range or JSON string.
 * @param {"kpis"} outputMode "kpis" (2-col summary), "schedule" (multi-period tie-out table), or "scalar:<metric_key>".
 * @return 2D spill array or scalar value.
 * @customfunction
 */
function QUANTLEDGER(engineCode, jurisdiction, inputRange, outputMode) {
  let parsedInputs = inputRange || null;
  if (typeof inputRange === 'string' && inputRange.trim().charAt(0) === '{') {
    parsedInputs = JSON.parse(inputRange);
  }
  return _qlInvokeBridge({
    formula_type: 'ENGINE',
    engine_code: engineCode || 'BI-17',
    jurisdiction: jurisdiction || 'DC',
    output_mode: outputMode || 'kpis',
    range_or_inputs: parsedInputs,
  });
}

/**
 * Batch-screens company or individual names against 138,000+ US OFAC SDN/SSI, Commerce BIS Entity List, ITAR, OIG & SEC records.
 * @param {A2:A20} entitiesRange Cell or range of counterparty names to screen.
 * @return 2D compliance screening spill table.
 * @customfunction
 */
function QUANTLEDGER_KYB(entitiesRange) {
  const list = Array.isArray(entitiesRange) ? entitiesRange : [[entitiesRange || 'Apple Inc.']];
  return _qlInvokeBridge({ formula_type: 'KYB', range_or_inputs: list });
}

/**
 * Pulls live SEC EDGAR Form D newly funded startups with CEO/CFO signer contact, phone, capital closed, IRC 409A & QSBS flags.
 * @param {"CA"} state Optional 2-letter US state filter (or "ALL").
 * @param {14} daysBack Lookback window in calendar days (1 to 90).
 * @param {250000} minSoldUsd Minimum closed capital in USD.
 * @return 2D live Form D fundraising leads spill table.
 * @customfunction
 */
function QUANTLEDGER_FORMD(state, daysBack, minSoldUsd) {
  return _qlInvokeBridge({
    formula_type: 'FORM_D',
    jurisdiction: state || 'ALL',
    days_back: Number(daysBack || 14),
    min_amount_usd: Number(minSoldUsd || 250000),
  });
}

/**
 * Screens 121,000+ DOL EBSA Form 5500 retirement plans for 80-120 CPA audit transitions, ERISA 408(b)(2) excess fees & late deferrals.
 * @param {"CA"} state Optional 2-letter US state filter (or "ALL").
 * @param {"FIRST_TIME_CPA_AUDIT_ZONE"} triggerFilter FIRST_TIME_CPA_AUDIT_ZONE, HIGH_FEE_BENCHMARK_ALERT, MISSING_CPA_AUDIT_OPINION, LATE_DEFERRAL_VIOLATION, or FIDELITY_BOND_SHORTFALL.
 * @param {500000} minAssetsUsd Minimum net plan assets in USD.
 * @return 2D DOL Form 5500 CPA audit & ERISA compliance spill table.
 * @customfunction
 */
function QUANTLEDGER_5500(state, triggerFilter, minAssetsUsd) {
  return _qlInvokeBridge({
    formula_type: 'FORM_5500',
    jurisdiction: state || 'CA',
    trigger_filter: triggerFilter || 'FIRST_TIME_CPA_AUDIT_ZONE',
    min_amount_usd: Number(minAssetsUsd || 500000),
  });
}

/**
 * Returns 57-jurisdiction US corporate tax rate, apportionment formula, Federal IRC Sec. 11 rate, and live NY Fed SOFR benchmark.
 * @param {"NY"} jurisdiction 2-letter US State, DC, Territory, or US code.
 * @return 2D statutory tax & benchmark rate table.
 * @customfunction
 */
function QUANTLEDGER_TAX(jurisdiction) {
  return _qlInvokeBridge({ formula_type: 'TAX', jurisdiction: jurisdiction || 'NY' });
}

2. Microsoft Excel — Automate Office Script & Desktop Power Query

A. Excel Web & Desktop Automate (Office Script TypeScript)

Download QuantLedger_Excel_OfficeScript.ts
/**
 * QuantLedger Microsoft Excel Automate (Office Script) — 2D Statutory & Compliance Spill Writer
 * Version: 2.8.2 | Docs: https://quantledgerapi.github.io/google-sheets-excel-formulas-and-n8n/
 *
 * HOW TO USE IN EXCEL (WEB OR DESKTOP):
 *   1. Open Excel -> Automate tab -> New Script -> paste this TypeScript file and click Save.
 *   2. Click Run (works immediately in free 12-row demo mode, or paste your RapidAPI key below for 100-row Pro mode).
 */

async function main(
  workbook: ExcelScript.Workbook,
  formulaType: string = "ENGINE",
  engineCode: string = "BI-17",
  jurisdiction: string = "NY",
  outputMode: string = "schedule",
  rapidApiKey: string = ""
): Promise<void> {
  const sheet = workbook.getActiveWorksheet();
  const usePro = rapidApiKey.trim().length > 0;
  const endpoint = usePro
    ? "https://quantledger-73-engine-financial-and-statutory-api.p.rapidapi.com/v1/spreadsheet/formula-eval"
    : "https://quantledger-ghost-kitchen-3yplwqtnha-uc.a.run.app/v1/public/spreadsheet-demo";

  const headers: Record<string, string> = { "Content-Type": "application/json" };
  if (usePro) {
    headers["X-RapidAPI-Key"] = rapidApiKey.trim();
    headers["X-RapidAPI-Host"] = "quantledger-73-engine-financial-and-statutory-api.p.rapidapi.com";
  }

  const response = await fetch(endpoint, {
    method: "POST",
    headers,
    body: JSON.stringify({
      formula_type: formulaType,
      engine_code: engineCode,
      jurisdiction,
      output_mode: outputMode,
      max_rows: usePro ? 50 : 12,
    }),
  });

  const payload = await response.json();
  if (!response.ok) {
    throw new Error(payload?.detail || `QuantLedger HTTP ${response.status}`);
  }

  const rows: (string | number | boolean)[][] = payload.rows || [["No data"]];
  const rowCount = rows.length;
  const colCount = rows[0].length;

  const targetRange = sheet.getRangeByIndexes(0, 0, rowCount, colCount);
  targetRange.setValues(rows);
  const headerRange = sheet.getRangeByIndexes(0, 0, 1, colCount);
  headerRange.getFormat().getFill().setColor("#131B33");
  headerRange.getFormat().getFont().setColor("#FFFFFF");
  headerRange.getFormat().getFont().setBold(true);
  targetRange.getFormat().autofitColumns();
}

B. Excel Desktop Power Query (Web.Contents M Function)

Download QuantLedger_PowerQuery.pq
// QuantLedger Microsoft Excel Desktop Power Query (M) Function — v2.8.2
// 1. In Excel Desktop: Data -> Get Data -> From Other Sources -> Blank Query -> Advanced Editor
// 2. Paste this query, click Done, and invoke fnQuantLedger("ENGINE", "BI-17", "NY", "schedule", "")
let
    fnQuantLedger = (
        formulaType as text,
        engineCode as text,
        jurisdiction as text,
        outputMode as text,
        optional rapidApiKey as nullable text
    ) as table =>
    let
        cleanKey = if rapidApiKey = null then "" else Text.Trim(rapidApiKey),
        usePro = Text.Length(cleanKey) > 0,
        targetUrl = if usePro
            then "https://quantledger-73-engine-financial-and-statutory-api.p.rapidapi.com/v1/spreadsheet/formula-eval"
            else "https://quantledger-ghost-kitchen-3yplwqtnha-uc.a.run.app/v1/public/spreadsheet-demo",
        reqHeaders = if usePro
            then [#"Content-Type"="application/json", #"X-RapidAPI-Key"=cleanKey, #"X-RapidAPI-Host"="quantledger-73-engine-financial-and-statutory-api.p.rapidapi.com"]
            else [#"Content-Type"="application/json"],
        bodyBytes = Json.FromValue([
            formula_type = formulaType,
            engine_code = engineCode,
            jurisdiction = jurisdiction,
            output_mode = outputMode,
            max_rows = if usePro then 100 else 12
        ]),
        rawResp = Web.Contents(targetUrl, [Headers = reqHeaders, Content = bodyBytes]),
        parsed = Json.Document(rawResp),
        rowsList = parsed[rows],
        colNames = List.Transform(rowsList{0}, each Text.From(_)),
        dataRows = List.Skip(rowsList, 1),
        outTable = Table.FromRows(dataRows, colNames)
    in
        outTable
in
    fnQuantLedger

3. Official n8n-nodes-quantledger Workflow Automation Node

Automate daily SEC Form D startup fundraising alerts into HubSpot/Slack, screen new Stripe/ERP customers against 138K+ OFAC/BIS/OIG watchlists, or route DOL Form 5500 CPA audit transitions into your CRM with zero custom HTTP boilerplate.

# Self-hosted n8n instant install from GitHub:
cd ~/.n8n/nodes
npm install git+https://github.com/QuantLedgerAPI/n8n-nodes-quantledger.git

# Or inside n8n Settings -> Community Nodes (once published to npm):
n8n-nodes-quantledger
View n8n-nodes-quantledger on GitHub Get RapidAPI Key for Production Workflows