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

DocsServiceApp

This is a Google Apps Script library for supporting Document service, Docs API, Spreadsheet service, Sheets API, Slides service and Slides API. The aim of this library is to compensate the processes that they services cannot achieve.

AI Summary

DocsServiceApp

Supports processes unachievable by Google Docs/Sheets/Slides services and APIs.

Target Users

Intermediate GAS developers building extensions for Spreadsheet images/comments, table widths, etc.

Problems Solved

Google Document/Sheets/Slides lack table widths, images/comments retrieval, custom header/footer Spreadsheet creation.

Script ID

  1. In GAS Editor: Click "Libraries +" → Paste into "Script ID" field → Click "Look up"
  2. "DocsServiceApp" will appear in the search results
  3. Select the latest version (highest number) from "Version" dropdown
  4. Click "Add"

Tags

Main Features
1
Image retrieval

Retrieves cell/over-cell images in Google Spreadsheets with position and blob from XLSX too.

2
Comments retrieval

Gets Spreadsheet comments with cell positions, supports XLSX files.

3
Table widths

Directly retrieves table/column widths in Google Docs and MS Word, including default tables.

Examples

Main Functions

FunctionDescription
DocsServiceApp.openByDocumentId().getTableColumnWidth()Get Document table column widths
DocsServiceApp.openBySpreadsheetId().getImages()Retrieve Spreadsheet images
DocsServiceApp.createNewSpreadsheetWithCustomHeaderFooter()Create Spreadsheet with custom headers

Examples

Retrieve Google Document table widths
/**
 * Googleドキュメント表列幅取得
 * ・ドキュメントオープン: DocsServiceApp.openByDocumentId(documentId)
 * ・列幅取得呼び出し: .getTableColumnWidth()
 * ・結果出力: console.log(res)
 */
function sampleDocumentTableWidths() {
  const documentId = "###"; // Google Document ID
  const res = DocsServiceApp.openByDocumentId(documentId).getTableColumnWidth();
  console.log(res);
}

Retrieve Spreadsheet images
/**
 * スプレッドシート画像取得
 * ・スプレッドオープン: DocsServiceApp.openBySpreadsheetId(spreadsheetId)
 * ・シート指定取得: .getSheetByName("Sheet1")
 * ・画像取得呼び出し: .getImages()
 */
function sampleSheetImages() {
  const spreadsheetId = "###"; // Google Spreadsheet ID
  const res = DocsServiceApp.openBySpreadsheetId(spreadsheetId)
    .getSheetByName("Sheet1")
    .getImages();
  console.log(res);
}

Create new Spreadsheet with custom headers
/**
 * カスタムヘッダー付き新規スプレッド作成
 * ・オブジェクト設定: {title: "sample", header: {l: "left", c: "center", r: "right"}}
 * ・親フォルダ指定: parent: "### folder ID"
 * ・作成呼び出し: DocsServiceApp.createNewSpreadsheetWithCustomHeaderFooter(object)
 */
function sampleCustomSpreadsheet() {
  const object = {
    title: "sample title",
    parent: "###",
    header: { l: "left header", c: "center header", r: "right header" },
    footer: { l: "left footer", c: "center footer", r: "right footer" },
  };
  const res = DocsServiceApp.createNewSpreadsheetWithCustomHeaderFooter(object);
  console.log(res);
}

Sample Code

Post a Sample

No sample codes for this library yet

Be the first to post a sample!

Post a Sample