Your AD Here (728x90)

Convert Excel file to Google Sheets ภาค 1

Your AD Here (728x90)


สำหรับคนที่กำลังฝึกเขียนโปรแกรมบน Google Apps Script นะครับ

เข้าไปที่ Apps script ที่ Google Drive จากนั้นก็ copy วาง จากนั้น ก็ Run ฟังก์ชันนี้ดูครับ
แต่ต้องลอง Upload ไฟล์ Excel หรือ Office ต่างลงไปดูนะครับ 

ลองศึกษาเขียนดูนะครับ  เพิ่มประสบการณ์ แหล่งทรงพลังของ Google กัน








// By Google Docs, we mean the native Google Docs format
// ไฟล์ ไม่โครซอฟ ออฟฟิศ ใช้ได้ทุกตัวครับ.......

function convertToGoogleDocs(fileName) {

var officeFile = DriveApp.getFileById("0BxzE9Mdx0o8MdldobnE0NUVfVWs");

// Use the Advanced Drive API to upload the Excel file to Drive
// convert = true will convert the file to the corresponding Google Docs format
var uploadFile = JSON.parse(UrlFetchApp.fetch(
"https://www.googleapis.com/upload/drive/v2/files?uploadType=media&convert=true",
{
method: "POST",
contentType: officeFile.getMimeType(),
payload: officeFile.getBlob().getBytes(),
headers: {
"Authorization" : "Bearer " + ScriptApp.getOAuthToken()
},
muteHttpExceptions: true
}
).getContentText());
// Remove the file extension from the original file name
var googleFileName = "testExcel";

// Update the name of the Google Sheet created from the Excel sheet
DriveApp.getFileById(uploadFile.id).setName(googleFileName);
}





อย่าลืมทำตามภาพด้วย เดี๋ยว Run ไม่ผ่านนะคร๊าฟ...





Follow Us

Posted By : cikapoung Date :

view_module Related

label Labels

Comments 0