Skip to content

tichavich/DevWeb-GoogleAppScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);
    };
    
  2. 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();
    };
    
  3. 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();
    };
    
  4. 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();
    };
    
  5. 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();
    };
    

About

Module GoogleAppScript for Google Sheet

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published