Converting .xls to google spreadsheet in google ap

2019-01-11 15:29发布

I have an .xls file stored in Google Drive. I want to convert it to the Google Sheets spreadsheet file format from Google Apps Script. Is there any way to do this without external solutions?

3条回答
趁早两清
2楼-- · 2019-01-11 15:42

Here's the complete code to create a file in a particular folder: (was a hint but was not completely apparent to me from @ben-visness comment)

var file = { 
    "title": filename, 
    "parents": [{"id": folderId}]
};
file = Drive.Files.insert(file, blobObj, {
    "convert": true
});

Note: This will require enabling advanced Drive service from within Google Apps Script - Menu > Resources > Advanced Google Services AND Menu > Resources > Advanced Google Services > Google API Console.

查看更多
孤傲高冷的网名
3楼-- · 2019-01-11 16:00

Other than using the delivered 'upload' and convert functions, it's not currently available. Requesting enhancement request here: http://code.google.com/p/google-apps-script-issues/issues/detail?id=1019

查看更多
啃猪蹄的小仙女
4楼-- · 2019-01-11 16:05

This is now possible using the Advanced Drive service:

https://developers.google.com/apps-script/advanced/drive

When using Drive.Files.insert, simply set the optional parameter "convert" to "true".

var file = {
    title: 'Converted Spreadsheet'
  };
  file = Drive.Files.insert(file, xlsxBlob, {
    convert: true
  });

This was also obtained from the above given issue

查看更多
登录 后发表回答