doGet là hàm trong Google Apps Script giúp ta lấy dữ liệu từ Google Sheet, dữ liệu lấy về có thể dạng Text, JSON ... thông qua HTML, từ đó ta có thể sử dụng JAVASCRIPT hay JQUERY để bóc tách xử lý dữ liệu.
doPost là hàm trong Google Apps Script giúp ta gởi dữ liệu từ trang web do ta thiết kế (đoạn html), khi đó ta viết code Google Apps Scripts để bóc tách và đưa dữ liệu đó vào các hàng của Google Sheet.
Hướng dẫn các lập trình chèn dữ liệu vào SQL Server khi thêm dòng Google Sheet
Bạn đang có 1 file google sheet, bạn cần nghiệp vụ:
Khi có ai đó thêm dữ liệu vào google sheet thì sẽ tự động chèn dữ liệu này vào cơ sỡ dữ liệu SQL Server
Bài 01: Ví dụ cơ bản nhất về doGet - Google sheet
function doGet(e){
const temp='Xin chao';
return ContentService.createTextOutput(temp );
}
function doGet(e){
const Myobj=[
{TT:1,Ten:'Nhat'},
{TT:2,Ten:'My'},
];
const val= JSON.stringify(Myobj);
//Logger.log(val);
return ContentService.createTextOutput(val).setMimeType(ContentService.MimeType.JSON);
}
function doGet(e){
const ID='15f7JTQBCu-VDtckq5i2aoie7Csvc0laRO1cZ61FpBT4';
const ss= SpreadsheetApp.openById(ID);
const data = ss.getSheets()[0].getDataRange().getValues();
const val= JSON.stringify(data);
//Logger.log(val);
return ContentService.createTextOutput(val).setMimeType(ContentService.MimeType.JSON);
}