diff --git a/export_pdf.gs b/export_pdf.gs index fa8c6bc..6f04b08 100644 --- a/export_pdf.gs +++ b/export_pdf.gs @@ -27,7 +27,8 @@ function exportSheetAsPdf(spreadsheetId, sheetName, folderId, includeTimestamp) `&left_margin=0.75` + `&right_margin=0.75` + `&printtitle=true` + // スプレッドシートのタイトルをヘッダーに挿入 - `&pagenum=CENTER`; // ページ番号をフッターに挿入 (より汎用的な設定) + `&pagenum=CENTER` + // ページ番号をフッターに挿入 (より汎用的な設定) + `&gridlines=false`; // グリッド線非表示 // 注: ヘッダーの右にエクスポート日時を挿入する、またはヘッダーの中心にワークブックのタイトルを挿入する // 直接的なURLパラメータはありません。`printtitle=true`は通常左上にタイトルを挿入します。 diff --git a/main.gs b/main.gs index 99336fc..430d885 100644 --- a/main.gs +++ b/main.gs @@ -2,7 +2,7 @@ function onOpen() { var ui = SpreadsheetApp.getUi(); var menu = ui.createMenu('出版'); menu.addItem('変更内容を登録', 'showCommitRevision') - menu.addItem('Google Chat に送信', 'mergeMain'); + menu.addItem('Google Chat に送信', 'mergeMainPermission'); menu.addToUi(); } @@ -15,6 +15,16 @@ function showCommitRevision() { SpreadsheetApp.getUi().showSidebar(html); } +// 本当に Google Chat に送信してよいか確認するダイアログ +function mergeMainPermission() { + var ui = SpreadsheetApp.getUi(); + var response = ui.alert("Google Chat に送信します", ui.ButtonSet.OK_CANCEL); + + if (response == "OK") { + mergeMain(); + } +} + // 変更内容の保存 function saveCommitRevision(changes) { const activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet(); @@ -75,6 +85,18 @@ function mergeMain() { changes.push(changelogs[i][2]) } + // 編集者のメールアドレスを取得 + var editorEmail = [] + for (let i = 0; i < changelogs.length; i++) { + editorEmail.push(changelogs[i][1]) + } + + // 出版者の情報を取得 + const publisherEmail = Session.getActiveUser().getEmail(); + const editorSheet = ss.getSheetByName(".editor"); + const editors = editorSheet.getRange(2, 1, editorSheet.getLastRow() - 1, 2).getValues(); + const publisherName = editors.find(row => row[0] === publisherEmail)[1]; + // バージョン表記の更新 // '.config'!B2: バージョン情報が記載されたせる const configSheet = ss.getSheetByName(".config") @@ -99,6 +121,11 @@ function mergeMain() { // Google Chat で送信 const message_content = { "sheetName": sheetName, + "publisher": { + "name": publisherName, + "email": publisherEmail + }, + "editor": Array.from(new Set(editorEmail)), "changes": changes, "download": { "color": color_data.sharingUrl, diff --git a/notice.gs b/notice.gs index 242be5b..da71820 100644 --- a/notice.gs +++ b/notice.gs @@ -13,12 +13,25 @@ function sendGooglechat(messageContents, webhookUrl) { // 送信するテキストメッセージ const textMessage = "「" + messageContents.sheetName + "」が更新されました。"; + + // 貢献者の情報 + let contributor = messageContents.editor; + contributor.push(messageContents.publisher.email); + contributor = Array.from(new Set(contributor)); + + var contributorMessage; + if (contributor.length - 1 > 0){ + contributorMessage = messageContents.publisher.name + " と他" + Number(contributor.length - 1) + "人の編集者"; + } else { + contributorMessage = messageContents.publisher.name + "によって出版"; + } // 送信するカードのJSON const cardMessage = { "header": { "title": messageContents.sheetName, + "subtitle": contributorMessage }, "sections": [ {