Skip to content

Instantly share code, notes, and snippets.

@ndthanh

ndthanh/code.gs Secret

Created August 23, 2020 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndthanh/2e7f5046c4d13dcf932f44f22746e3b3 to your computer and use it in GitHub Desktop.
Save ndthanh/2e7f5046c4d13dcf932f44f22746e3b3 to your computer and use it in GitHub Desktop.
function createMenu() {
const ui = SpreadsheetApp.getUi();
const menu = ui.createMenu("Customer Management System");
menu.addItem("Mở userform (sidebar)", "loadCustomerForm");
menu.addItem("Mở userform (Modal)", "loadCustomerFormModal");
menu.addItem("Mở userform (Modeless)", "loadCustomerFormModeless");
menu.addToUi();
}
function loadCustomerForm() {
const html = HtmlService.createHtmlOutputFromFile("index").setTitle("dtnguyen.business");
const ui = SpreadsheetApp.getUi();
// ui.showModalDialog(html, "Customer Management System");
// ui.showModelessDialog(html, "Customer Management System");
ui.showSidebar(html);
}
function loadCustomerFormModal() {
const width = 640;
const height = 480;
const html = HtmlService.createHtmlOutputFromFile("index");
html.setWidth(width).setHeight(height);
const ui = SpreadsheetApp.getUi();
ui.showModalDialog(html, "Customer Management System");
}
function loadCustomerFormModeless() {
const width = 640;
const height = 480;
const html = HtmlService.createHtmlOutputFromFile("index");
html.setWidth(width).setHeight(height);
const ui = SpreadsheetApp.getUi();
ui.showModelessDialog(html, "Customer Management System");
}
function onOpen() {
createMenu();
}
function dienDuLieu(data) {
const ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("data");
ws.appendRow([data.id, data.firstName, data.lastName, data.email]);
}
function errMessage() {
Browser.msgBox("Bạn cần điền đầy đủ tất cả các trường!");
}
@toanqlcn
Copy link

Trên https://blog.hocexcel.online chỉ nói
Các bạn sẽ cần thiết lập một bảng tính Google Sheets mới gồm có 4 cột: ID, First Name, Last Name, Email.
mà không ghi rõ hơn là SheetName là data luôn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment