Search code examples
excelgoogle-apps-scriptgoogle-sheetsdrive

trying to convert xls to google spreadsheet using google app script and getting "Empty response" error


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?


Solution

  • 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});