https://github.com/tichavich/devweb-googleappscript
Module GoogleAppScript for Google Sheet
https://github.com/tichavich/devweb-googleappscript
api appscript google googleappscripts googlesheets googlesheetsapi
Last synced: 11 months ago
JSON representation
Module GoogleAppScript for Google Sheet
- Host: GitHub
- URL: https://github.com/tichavich/devweb-googleappscript
- Owner: tichavich
- Created: 2023-07-02T07:54:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-03T16:22:22.000Z (over 1 year ago)
- Last Synced: 2025-01-06T01:15:02.749Z (about 1 year ago)
- Topics: api, appscript, google, googleappscripts, googlesheets, googlesheetsapi
- Language: HTML
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DevWeb-GoogleAppScript
### DevWeb-GoogleAppScript คืออะไร
เป็นโปรเจคที่สร้างขึ้นมาใช้สำหรับเช็คการเข้าทำงานหรือเข้าร่วมกิจกรรมของบริษัท โดยสร้างเขียน Google AppScript สร้างเป็นหน้าเว็บไซต์และเชื่อมต่อกับ GoogleSheet API เพือใช้เก็บข้อมูล
### ฟังก์ชั่นที่ทำงานร่วมกับ GoogleSheet
1. CreateDataSet ฟังก์ชั่นเขียนข้อมูล ต่อจาก Record ล่าสุด
function :
```
CreateDataSet=(sheet_index,data)=>{
let conSheet = SpreadsheetApp.openById(APPCONFIG.IDConnectSheet);
let selectSheet = conSheet.getSheetByName(APPCONFIG.sheetName[sheet_index]);
selectSheet.appendRow(data);
};
```
3. ReadDataOnceforCell ฟังก์ชั่นอ่านค่าข้อมูล โดยระบุตำแหน่งการเข้าถึงช่องเซลล์ เช่น A15 B26
function :
```
const ReadDataOnceforCell=(sheet_index,cell_name)=>{
let conSheet = SpreadsheetApp.openById(APPCONFIG.IDConnectSheet);
let selectSheet = conSheet.getSheetByName(APPCONFIG.sheetName[sheet_index]);
return selectSheet.getRange(cell_name).getValue();
};
```
5. ReadDataOnceforRowCol ฟังก์ชั่นอ่านค่าข้อมูล โดยระบุเป็นตัวเลขตำแหน่งแนวแถวและแนวคอลัมน์ เช่น ReadDataOnceforRowCol(1,5) 1 = ตำแหน่งแถว, 8 = ตำแหน่งคอลัมน์ ถ้าเป็นช่องเซลล์ก็เป็น H1
function :
```
const ReadDataOnceforRowCol=(sheet_index,row_num,col_num)=>{
let conSheet = SpreadsheetApp.openById(APPCONFIG.IDConnectSheet);
let selectSheet = conSheet.getSheetByName(APPCONFIG.sheetName[sheet_index]);
return selectSheet.getRange(row_num,col_num).getValue();
};
```
7. ReadDataOnceforRangeRowCol ฟังก์ชั่นอ่านค่าข้อมูล โดยระบุเป็นตัวเลขตำแหน่งแนวแถวและแนวคอลัมน์ กำหนดช่วงข้อมูล เช่น (1 = row,3 = column,5 = row,8 = column) ถ้าเป็นช่วงเซลล์ก็เป็น C1:H5
function :
```
const ReadDataOnceforRangeRowCol=(sheet_index,row,col,numRow,numCol)=>{
let conSheet = SpreadsheetApp.openById(APPCONFIG.IDConnectSheet);
let selectSheet = conSheet.getSheetByName(APPCONFIG.sheetName[sheet_index]);
return selectSheet.getRange(row,col,numRow,numCol).getValues();
};
```
9. ReadDataAll ฟังก์ชั่นอ่านค่าข้อมูลทั้งหมดที่อยุ่ใน Sheet
function :
```
const ReadDataAll=(sheet_index)=>{
let conSheet = SpreadsheetApp.openById(APPCONFIG.IDConnectSheet);
let selectSheet = conSheet.getSheetByName(APPCONFIG.sheetName[sheet_index]);
return selectSheet.getDataRange().getValues();
};
```