adjust the no of rows in sheet based on the number

2019-08-17 13:31发布

With a help from a friend,I have a code that uploads a txt file and here it is.

 document.getElementById('file').onchange = function(){

    var file = this.files[0];

    var reader = new FileReader();
    reader.onload = function(progressEvent){
    // Entire file
    console.log(this.result);

    // By lines
    var lines = this.result.split('\n');
    for(var line = 0; line < lines.length; line++){
        // By tabs
        var tabs = lines[line].split('\\t');
        for(var tab = 0; tab < tabs.length; tab++){    
                console.log(tabs[tab]);
        }   
    }
  };
  reader.readAsText(file);
};
<input type="file" name="file" id="file">

and this is my code.gs

function doGet(e){
  var html = HtmlService.createHtmlOutputFromFile("index");
  return html;
}

function work(res){
  var ss = SpreadsheetApp.getActiveSheet();
  ss.getRange(1,1,res.length,res[0].length).setValues(res);
}

The output of this code is :

  1. Upload a Tab Seperated File

  2. Convert that file into array

  3. Insert that array in Google Sheet

Actually the code is working but there is a problem. the google sheet has an initial of 1000 rows and I encountered a scenario where I will upload a file that contains million rows. How can I adjust the no. of rows in sheet based on the number of arrays.

0条回答
登录 后发表回答