Google sheet Apps script | Tự động Sắp xếp dữ liệu theo cột bất kỳ Auto Sort by Column
Google sheet Apps script, tự động Sắp xếp dữ liệu theo cột bất kỳ (Auto Sort by Column). Sau đây là code được sử dụng trong apps script, bạn có thể xem thêm video hướng dẫn ở bên dưới.
Các bài excel ứng dụng thực tế:
- Google sheet webapp|Nhập liệu-Quản lý khách hàng – Click tên hiển thị popup thông tin thêm – Print
- Google sheet webapp | Multi Load table data từ google sheet lên web và frezee header of table.
- HTML WEBAPP CSS -Mô phỏng hệ mặt trời -Trái đất -Mặt trăng đơn giản trên nền vũ trụ đen sao lấp lánh
- Google sheet Webapp Script | Tìm kiếm, lọc và In chi tiết thông tin sản phẩm của mã Khách hàng
- Google sheet Apps script | Data Entry Popup From – Thêm mới – Chỉnh sửa – Xóa
- Google sheet Webapp Script | Quản lý đặt xe cho chuyến đi – Tài xế cập nhật hoàn thành thông tin
- Apps script Webapp | Lấy giá trị Input hiển thị lên – Web Get value input field display on web
- Google sheet Apps script | Todo List and Send mail – Tạo danh sách nhắc việc và gửi mail
- Web App Script | Bộ Icon CSS Rất dễ lập trình cho giao diện webapp
- Google sheet Webapp | Project Quản lý khách hàng – Cập nhật tiến độ sửa chữa
Code trong apps cript
function onOpen(){
autoSort();
}
function onEdit(){
autoSort();
}
function autoSort() {
let ws = SpreadsheetApp.getActiveSpreadsheet();
let ss=ws.getSheetByName("Data");
let startingRange = ss.getDataRange();
let data =startingRange.getValues();
data.shift();
data.sort((a,b)=>a[0]-b[0]) //ascemding
//data.sort((a,b)=>b[3]-a[3]) //decreasing
let formulaRange = ss.getRange(2,4,data.length)
let formulas=formulaRange.getFormulas()
let finalRange=ss.getRange(2,1,data.length,data[0].length)
finalRange.setValues(data)
formulaRange.setFormulas(formulas)
}