บริการชีตขั้นสูงให้คุณเข้าถึง API ของชีตได้โดยใช้ Apps Script API นี้ช่วยให้สคริปต์อ่าน แก้ไข จัดรูปแบบ และแสดงข้อมูลใน Google ชีตได้ เช่นเดียวกับบริการ Google ชีต API ในตัวของ Apps Script ในกรณีส่วนใหญ่ บริการในตัวจะใช้งานง่ายกว่า แต่ บริการขั้นสูงจะมีคุณลักษณะเพิ่มเติมเล็กน้อย
ข้อมูลอ้างอิง
สำหรับข้อมูลโดยละเอียดเกี่ยวกับบริการนี้ โปรดดูที่ เอกสารอ้างอิงสำหรับ Sheets API บริการชีตขั้นสูงจะใช้ออบเจ็กต์ เมธอด และพารามิเตอร์เดียวกันกับ API สาธารณะเช่นเดียวกับบริการขั้นสูงทั้งหมดใน Apps Script ดูข้อมูลเพิ่มเติมได้ที่วิธีกำหนดลายเซ็นของเมธอด
หากต้องการรายงานปัญหาและค้นหาการสนับสนุนอื่นๆ โปรดดูที่ คู่มือการสนับสนุนชีต
โค้ดตัวอย่าง
โค้ดตัวอย่างด้านล่างใช้ API เวอร์ชัน 4 นี่เป็นเวอร์ชันเดียวของ Sheets API ที่ขณะนี้มีให้บริการเป็น บริการขั้นสูงใน Apps Script
อ่านค่าจากช่วง
ตัวอย่างต่อไปนี้แสดงวิธีอ่านค่าข้อมูลจากแอตทริบิวต์ที่ระบุ ในชีตด้วยบริการขั้นสูงของชีต ซึ่งเทียบเท่ากับ อ่านช่วงเดียว ตัวอย่างสูตรอาหาร
เขียนค่าไปยังหลายช่วง
ตัวอย่างต่อไปนี้แสดงวิธีเขียนข้อมูลไปยังข้อมูลที่ไม่ต่อเนื่องที่แตกต่างกัน ในชีตที่มีคำขอเดียว ซึ่งเทียบเท่ากับตัวอย่างสูตร เขียนไปยังหลายช่วง
เพิ่มชีตใหม่
ตัวอย่างต่อไปนี้แสดงวิธีการสร้างชีตใหม่ด้วย ขนาดและสีแท็บ ซึ่งเทียบเท่ากับ ตัวอย่างสูตรอาหารแบบเพิ่มชีต
สร้างตาราง Pivot
ตัวอย่างต่อไปนี้แสดงวิธีสร้างตาราง Pivot จากข้อมูลต้นทาง ซึ่งเทียบเท่ากับการเพิ่มตาราง Pivot ตัวอย่างสูตรอาหาร