StoryBook
ตัวอย่าง

เมื่อท่านได้สำเนาไฟล์ไปแล้ว แก้ไขดังนี้
1. ย้ายไฟล์ เข้าโฟลเดอร์ ที่ต้องการ เช่น
25681208 Web App ระบบชำระค่าเรียนพิเศษ
2. เปลี่ยนใน Code.gs Logo บรรทัดที่ 30
4. Deploy Program
🚀 ขั้นตอนการดีพลอยโปรแกรม Web App (Google Apps Script)
✅ 1) เปิด Script Editor / Apps Script
เปิด Google Sheet ที่ใช้เก็บข้อมูล (เช่น sports)
ไปที่เมนู ส่วนขยาย (Extensions) → Apps Script
เปิด Google Sheet ที่ใช้เก็บข้อมูล (เช่น
sports)ไปที่เมนู ส่วนขยาย (Extensions) → Apps Script
✅ 2) วางไฟล์ code.gs
นำโค้ด code.gs ที่ผมให้
→ วางในไฟล์ code.gs
→ กด Save (Ctrl + S)
นำโค้ด code.gs ที่ผมให้
→ วางในไฟล์ code.gs
→ กด Save (Ctrl + S)
✅ 3) สร้างไฟล์ index.html
คลิกซ้ายที่โฟลเดอร์ขวามือ → ไฟล์ใหม่ → HTML
ตั้งชื่อ: index
วาง index.html ฉบับเต็มที่ผมให้
กดบันทึก
คลิกซ้ายที่โฟลเดอร์ขวามือ → ไฟล์ใหม่ → HTML
ตั้งชื่อ: index
วาง
index.htmlฉบับเต็มที่ผมให้กดบันทึก
✅ 4) ตรวจสอบ doGet()
ต้องมีใน code.gs:
ต้องมีใน code.gs:
function doGet() {
ensureBaseSheets_();
const t = HtmlService.createTemplateFromFile('index'); // ใช้ไฟล์ index.html ในโปรเจ็กต์
const html = t.evaluate()
.setTitle('ระบบค่าเรียนพิเศษ')
.setFaviconUrl("https://knid1515.github.io/Pict_All/Krunid_Logo/krunid-002.png")
.addMetaTag('viewport', 'width=device-width , initial-scale=1')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
return html;
}
✅ 5) ตรวจสอบสิทธิ์การเข้าถึงชีต
✅ 6) Deploy เป็น Web App
กดปุ่ม Deploy มุมขวาบน
เลือก New Deployment
เลือกประเภท: Web App
ใส่ชื่อ: ระบบชำระค่าเรียนพิเศษ
Execute as:
✔ Me (ตัวเรา)
Who has access:
✔ Anyone หรือ Anyone with the link
กด Deploy
Google จะขอสิทธิ์ → กด Allow
กดปุ่ม Deploy มุมขวาบน
เลือก New Deployment
เลือกประเภท: Web App
ใส่ชื่อ:
ระบบชำระค่าเรียนพิเศษExecute as:
✔ Me (ตัวเรา)Who has access:
✔ Anyone หรือ Anyone with the linkกด Deploy
Google จะขอสิทธิ์ → กด Allow
✅ 7) เสร็จสิ้น — ได้ลิงก์ Web App
ระบบจะให้ลิงก์เช่น:
เอาไปเปิดใช้งาน / ใส่ใน QR / แชร์ครูได้เลย 🎉
ระบบจะให้ลิงก์เช่น:
เอาไปเปิดใช้งาน / ใส่ใน QR / แชร์ครูได้เลย 🎉
🎯 จุดสำคัญที่ต้องระวัง
🟥 1. HTML ต้องใช้ index เท่านั้น
ถ้าใช้ชื่ออื่น ให้แก้ doGet()
ถ้าใช้ชื่ออื่น ให้แก้ doGet()
🟦 2. ต้องใช้ .setXFrameOptionsMode(...ALLOWALL)
เพื่อให้ UI โหลดครบ (Tailwind, CSS)
เพื่อให้ UI โหลดครบ (Tailwind, CSS)
🟩 3. ถ้ามี Refused to execute script
ให้เช็กว่า
script ใน <script> ไม่ใส่ type="module"
ไม่มี HTML แปลก ๆ ติดคอมเมนต์
ให้เช็กว่า
script ใน
<script>ไม่ใส่ type="module"ไม่มี HTML แปลก ๆ ติดคอมเมนต์
🟧 4. ถ้ามี “Permission denied”
คือไม่ได้เปิด Sheets API หรือไม่ได้ตั้ง Execute as = Me
คือไม่ได้เปิด Sheets API หรือไม่ได้ตั้ง Execute as = Me










