반응형

GAS 63

Apps Script로 Google Sheets의 정렬(sort) 적용하기

💡 Apps Script로 Google Sheets에서 정렬을 적용하는 방법을 알아본다. 데이터를 조회할 때 쿼리문의 order by 절에서 정렬을 해 줄 수도 있지만, Script로 처리하는 방법을 구현해본다. 아래와 같은 데이터가 있다. 일단 간단하게 첫번 째 행인 country 를 내림차순 정렬해보자. 정렬은 sort() 를 이용해 수행한다. 사용 방법은 sheet 안에 range 영역에서 sort를 수행하면 된다. function createSort() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheetByName("tempature_all"); const range = sheet.getRange("A:E");..

GCP/Apps Script 2023.03.07

Apps Script로 Google Sheets의 Filter 설정하기

💡 Apps Script로 Google Sheets에서 필터를 생성하고, 조건을 적용해 본다. 나아가 필터 조건이 적용된 데이터를 새로운 시트로 추출해본다. 아래와 같은 데이터가 있다. 필터 생성하기 function createFilters() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheetByName("tempature_all"); const range = sheet.getRange("A:E"); range.createFilter(); } 필터 삭제하기 function createFilters() { const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet =..

GCP/Apps Script 2023.03.02

Apps Script로 Google Sheets의 영역(카테고리) 별 음영 처리

💡 Apps Script로 BigQuery의 데이터를 Google Sheets에 뿌려주고, 데이터의 case에 따른 음영을 처리하는 예제이다. Apps Script로 BigQuery 데이터를 Google Sheets에 뿌려주기 그럼, 데이터를 조회해서 바로 Google Sheets에 바로 뿌려줄 수 있는 기능을 구현해본다. 초기에 작성한 부분이라, 모든 함수를 호출 할 때 SheetUrl, SheetName 을 계속 호출하는데 excuteA(sheetUrl, sheetName); whiseung.tistory.com BigQuery에서 데이터를 가져와서 Google Sheet에 뿌려주었다. 추가 요구 사항이 들어왔다. [매출실적] [매출분석] [원가] 별로 동일한 음영 처리를 해야 한다. 흠... App..

GCP/Apps Script 2023.02.17

Apps Script로 Google Sheets의 검색조건 Dropdown 선택 시 다른 셀에 하위정보 뿌려주기 (vlookup 대체)

💡Google Sheet에서, vlookup 함수를 Apps Script 의 event trigger를 이용해 구현해본다. vlookup 수식으로 작성해 놓았을 경우, 작성된 셀에서 delete키를 눌럿을 경우 수식이 삭제되기 때문에, event trigger를 이용해 구현해보았다. 조회조건인 명칭을 dropdown 에서 선택하면, 해당하는 시도와 지사를 자동으로 뿌려줘본다. 1. 마스터 데이터 가져오기 '공통데이터' 시트의 데이터를 가져온다. function getMasterData() { const ss = SpreadsheetApp.getActive(); const masterSheet = ss.getSheetByName("공통데이터"); const masterData = masterSheet.ge..

GCP/Apps Script 2023.02.16

Apps Script로 이미지파일/PDF 파일 OCR 하기

💡Apps Script를 이용해 이미지나 pdf파일에서 텍스트를 추출해본다. 작동방식은 이미지나 pdf 파일을 Google Drive에 OCR 된 형태의 임시 파일로 upload 하는 방식이다. Apps Script 좌측 메뉴에서 서비스의 [+] 버튼을 클릭해 Drive 서비스를 찾아 추가한다. PDF 파일 ocr 원본 pdf 스크립트 function readTextFromFile() { const url = "https://www.africau.edu/images/default/sample.pdf"; const contentBlob = UrlFetchApp.fetch(url).getBlob(); const resource = { title : contentBlob.getName(), mimeType :..

GCP/Apps Script 2023.02.15

Apps Script 라이브러리 생성해서 다른 Apps Script에서 사용하기 - 실제 사용 예

💡 Apps Script 를 이용해 실제로 개발했던 내용을 요약했다. Apps Script 라이브러리 생성해서 다른 Apps Script에서 사용하기 💡 Apps Script 프로젝트를 진행함에 있어, 유지보수를 용이하기 위해서, 공통모듈을 라이브러리로 배포하여 사용하는 방법이다. https://whiseung.tistory.com/4 Apps Script 개발을 위한 구조 설계 💡Apps Scri whiseung.tistory.com 위에서 Apps Script의 구조를 간략히 설명했는데, 사용 예시와 함께 좀 더 디테일하게 작성해 보았다. 서울 영업부서 Google Sheet와 연결 된 Apps Script (껍데기) Google Sheets 메뉴에서 [확장프로그램] - [Apps script] 로 ..

GCP/Apps Script 2023.02.14

Apps Script로 Google Sheets의 데이터를 생성한 웹페이지에서 보여주기

Apps Script로 생성한 웹페이지에서(웹앱 배포) 입력한 값을 Google Sheets에 저장하기 https://whiseung.tistory.com/entry/Apps-Script%EB%A1%9C-%EC%9B%B9%EC%95%B1-%EC%83%9D%EC%84%B1 Apps Script로 간단한 웹페이지 생성하기 Apps Script로 간단한 웹페이지를 생성 할 수 있다. 이 웹페이지에서 Bigquery, Database, Goog whiseung.tistory.com 전에는 Web → Google Sheets 를 구현했엇다. 이제는 Google Sheets → Web 을 구현해보려 한다. Google Sheets 에서 가져올 데이터 Google Sheets를 url 기반으로 가져와, 데이터를 추출..

GCP/Apps Script 2023.02.10

Apps Script로 Google Sheets의 Chart 생성

Apps Script를 이용해, Google Sheets에서 chart를 생성해본다. 아래와 같은 표가 있다. SpreadSheetApp의 newChart() 함수를 이용한다. chart라는 변수에 생성할 chart를 담아주고, insertChart 에서 chart를 build해준다. 한줄짜리 라인차트 생성 function makeSingleLineChart() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("차트_테스트"); const range = sheet.getRange("A2:B13"); const chart = sheet.newChart().setChartType(Charts.ChartType.LINE) .addRan..

GCP/Apps Script 2023.01.31

Apps Script로 Google Sheets의 Checkbox 생성 후, Checkbox 조작하기

Apps Script를 이용해, 1. Google Sheets에 Checkbox를 생성 2. 체크가 되엇을떄 다음셀에 값을 입력 3. 체크된 checkbox 수 세기 4. 전체선택/전체선택해제 를 해보겠다. 체크박스 생성 function createCheckbox() { const sheetName = "sheetNameHere"; const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); sheet.getRange("B2:B10").insertCheckboxes(); } 체크박스 선택 edit event 체크박스 선택 시, 앞 셀의 값을 뒷 셀에 뿌려주기. /** * edit event * @param {object} e..

GCP/Apps Script 2023.01.25

Apps Script로 Google Sheets의 sheets들 index(목차) 만들기

엑셀 인 Google Sheets 는 sheet를 계속 생성할 수 있다. 한 파일 안에 sheet 들을 목차 형식으로 빼고싶어졌다. 현재 개발중인 Google sheets의 sheet 들. 일단, Google Sheets 의 sheet 이름들을 가져온다. function getSheetsNameAndCreateIndex() { const sheet = SpreadsheetApp.getActiveSpreadsheet(); const sheets = sheet.getSheets(); for ( i in sheets ) { const sheetName = sheets[i].getName(); console.log(sheetName); } } 시트이름과, URL 링크를 목차라는 sheet 에 뿌려줘본다. fun..

GCP/Apps Script 2023.01.13
반응형