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:
- Biến Google Sheets thành Dashboard “Viễn Tưởng” phong cách Cyberpunk
- Google appscript | Hệ thống tìm thông tin và nhập liệu 2 Form-Tự động truy vấn và upload nhiều files
- Google sheet Webapp|Giáo viên chủ nhiệm quản lý điểm, thống kê xếp hạng chia sẻ cho phụ huynh
- Google sheet Webapp | Bản nâng cấp Tìm và Load Thông tin sinh viên có Hình ảnh và Bảng kết quả thi
- Google webapp | Form tìm, hiển thị kết quả học tập nhiều môn và in phiếu kết quả
- Danh mục các Bài học Google sheet Apps script Cơ bản
- Bản Nâng cấp Hệ thống hóa đơn Phân quyền Quản lý khách Quản lý sản phẩm Quản lý hóa đơn
- Tạo webapp import và update dữ liệu từ Excel lên Google sheet có Load bảng Table lên nền tảng web
- Google sheet, appscript và webapp – Giải pháp thu hoạc phí toàn diện
- Quản Lý Học Phí Bằng Google Apps Script: Form CRUD, Tìm Kiếm, In Phiếu Thu và Tự Động Tính Toán
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>
