trying to convert xls to google spreadsheet using

2019-04-16 22:01发布

I'm trying to convert a xls file to a google spreadsheet with the following code:

  var searchFor ="fullText contains 'theFile.xls' and '" + FolderId + "' in parents";  
  var files = DriveApp.searchFiles(searchFor); 
  var file = files.next().getBlob();  
  var convertedFileinfo = {
    title: 'theFile',
    parents:[{id: FolderId}]
  };
  Drive.Files.insert(convertedFileinfo, file, {
    convert: true,
    uploadType:'resumable'
  })

But i'm getting "Empty response" error on Drive.Files.insert line...

What I'm doing wrong?

2条回答
放我归山
2楼-- · 2019-04-16 22:17

I finally get it to work using copy:

  var searchFor ="fullText contains 'theFile.xls' and '" + FolderId + "' in parents"; 
  var files = DriveApp.searchFiles(searchFor); 
  var xlsFile = files.next();    
  Drive.Files.copy({}, xlsFile.getId(), {convert: true}); 
查看更多
姐就是有狂的资本
3楼-- · 2019-04-16 22:35

How about following change?

From :

Drive.Files.insert(convertedFileinfo, file, {
  convert: true,
  uploadType:'resumable'
})

To :

Drive.Files.insert(convertedFileinfo, file, {
  convert: true
})
查看更多
登录 后发表回答