HTML Apps script Lấy dữ liệu từ CELL Spreadsheet lên Browser
Trong ví dụ này chúng ta sẽ sử dụng một số kiến thức về html, google sheet, apps script để lấy dữ liệu từ Cell Spreadsheet và hiển thị giá trị đó lên trình duyệt web (Browser).
Các bài excel thực hành ứng dụng khác:
- 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
- Google sheet Apps script Webapp | Login form OTP xác minh qua email, Chuyển link cho từng User
- Web App Script CSS JS | Tạo hiệu ứng Click button Nổ tung các mảnh giấy và chuyển link
- Web App Script CSS | Tạo button Liên hệ gồm 3 option đẹp mắt cho trang web
Mã trong file Code.gs
function doGet(e){
return HtmlService.createHtmlOutputFromFile("index.html");
}
function getDatacell() {
var sw=SpreadsheetApp.getActiveSpreadsheet();
var ss=sw.getActiveSheet();
let dataCell = ss.getRange("C3").getValue();
let display="<span>" +dataCell+ "</span>";
return display;
}
Mã trong file index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<title>Lấy dữ liệu từ Cell của Spreadsheet, hiển thị lên Browser</title>
</head>
<body >
<table align="center">
<tr>
<td style="color: blue; font-size:3em; font-weight:bold;">Tổng số lượng: </td>
<td style="text-align:c enter; color: red; font-size:3em; font-weight:bold;" id="result">ds</td>
</tr>
</table>
<script>
let loading = "Đang lấy dữ liệu...";
document.querySelector('#result').innerHTML=loading;
function onSuccess(response){
let result = "<span>"+response+"</span>";
document.querySelector('#result').innerHTML=result;
}
google.script.run.withSuccessHandler(onSuccess)
.getDatacell();
</script>
</body>
</html>