Skip to main content
added 53 characters in body
Source Link

I wrote a script to display a list of names and folder IDs.

The script that I wrote like this:

function listFolders() {

var sheet = SpreadsheetApp.getActiveSheet();
  sheet.getRange('A2:B').clear();
  //sheet.appendRow(["Name", "Folder-Id"]);

var folderID = DriveApp.getFolderById("1Hp_dM8WR0mGDT5q-a-VS-VVtl5dNCLfe");
var contents = folderID.getFolders();

var cnt = 0;
var lFolder;

while (contents.hasNext()) {
    var lFolder = contents.next();
    cnt++;

       data = [
            lFolder.getName(),
            lFolder.getId(),
        ];

         sheet.appendRowgetRange(2, 1, data.length, data[0].length).setValues(data); //modified
    };
};

I want to add new data in column C. After I fill in a text in column C, then I run the script. But the second row is empty.

enter image description here

I wrote a script to display a list of names and folder IDs.

The script that I wrote like this:

function listFolders() {

var sheet = SpreadsheetApp.getActiveSheet();
  sheet.getRange('A2:B').clear();
  //sheet.appendRow(["Name", "Folder-Id"]);

var folderID = DriveApp.getFolderById("1Hp_dM8WR0mGDT5q-a-VS-VVtl5dNCLfe");
var contents = folderID.getFolders();

var cnt = 0;
var lFolder;

while (contents.hasNext()) {
    var lFolder = contents.next();
    cnt++;

       data = [
            lFolder.getName(),
            lFolder.getId(),
        ];

         sheet.appendRow(data);
    };
};

I want to add new data in column C. After I fill in a text in column C, then I run the script. But the second row is empty.

enter image description here

I wrote a script to display a list of names and folder IDs.

The script that I wrote like this:

function listFolders() {

var sheet = SpreadsheetApp.getActiveSheet();
  sheet.getRange('A2:B').clear();
  //sheet.appendRow(["Name", "Folder-Id"]);

var folderID = DriveApp.getFolderById("1Hp_dM8WR0mGDT5q-a-VS-VVtl5dNCLfe");
var contents = folderID.getFolders();

var cnt = 0;
var lFolder;

while (contents.hasNext()) {
    var lFolder = contents.next();
    cnt++;

       data = [
            lFolder.getName(),
            lFolder.getId(),
        ];

         sheet.getRange(2, 1, data.length, data[0].length).setValues(data); //modified
    };
};

I want to add new data in column C. After I fill in a text in column C, then I run the script. But the second row is empty.

enter image description here

Source Link

Displays data arrays with appendrow where other columns contain data

I wrote a script to display a list of names and folder IDs.

The script that I wrote like this:

function listFolders() {

var sheet = SpreadsheetApp.getActiveSheet();
  sheet.getRange('A2:B').clear();
  //sheet.appendRow(["Name", "Folder-Id"]);

var folderID = DriveApp.getFolderById("1Hp_dM8WR0mGDT5q-a-VS-VVtl5dNCLfe");
var contents = folderID.getFolders();

var cnt = 0;
var lFolder;

while (contents.hasNext()) {
    var lFolder = contents.next();
    cnt++;

       data = [
            lFolder.getName(),
            lFolder.getId(),
        ];

         sheet.appendRow(data);
    };
};

I want to add new data in column C. After I fill in a text in column C, then I run the script. But the second row is empty.

enter image description here