Skip to main content
added 417 characters in body
Source Link

Update It is now working,i dont know if google fix it or what. But if i use the image function and use the script below to find the id from the folder it works. Here is my final text if someone would need (this is not script, this is a spreadsheet funktion)

=image(TEXTJOIN("",True,"https://docs.google.com/uc?export=download&id=",index(SPLIT(Sort!P2,"/"),5)))

"Sort!p2" is where the image id is.

I have an image in a folder that I want to import into my spreadsheet (in a cell). I'm using the script from Insert image from Google Drive into Google Sheets (with some modifications).

But this only works on one of the images.

I could see that the other image is a .png and the first image was a .jpg. I tried to convert the .png into .jpg, but it still does not work.

The modified script:

function listFilesInFolder(folderName) {
//writes the headers for the spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Image"]);
var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";

var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();

var cnt = 0;
var file;

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

    Logger.log(file);
    Logger.log(cnt);
    // writes the various chunks to the spreadsheet- just delete anything you don't want
        data = [
           
            "https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
            file.getDescription(),
            "=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
        ];

        sheet.appendRow(data);
};
};

The spreadsheet

Google drive folder Scripts

I have an image in a folder that I want to import into my spreadsheet (in a cell). I'm using the script from Insert image from Google Drive into Google Sheets (with some modifications).

But this only works on one of the images.

I could see that the other image is a .png and the first image was a .jpg. I tried to convert the .png into .jpg, but it still does not work.

The modified script:

function listFilesInFolder(folderName) {
//writes the headers for the spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Image"]);
var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";

var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();

var cnt = 0;
var file;

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

    Logger.log(file);
    Logger.log(cnt);
    // writes the various chunks to the spreadsheet- just delete anything you don't want
        data = [
           
            "https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
            file.getDescription(),
            "=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
        ];

        sheet.appendRow(data);
};
};

The spreadsheet

Google drive folder Scripts

Update It is now working,i dont know if google fix it or what. But if i use the image function and use the script below to find the id from the folder it works. Here is my final text if someone would need (this is not script, this is a spreadsheet funktion)

=image(TEXTJOIN("",True,"https://docs.google.com/uc?export=download&id=",index(SPLIT(Sort!P2,"/"),5)))

"Sort!p2" is where the image id is.

I have an image in a folder that I want to import into my spreadsheet (in a cell). I'm using the script from Insert image from Google Drive into Google Sheets (with some modifications).

But this only works on one of the images.

I could see that the other image is a .png and the first image was a .jpg. I tried to convert the .png into .jpg, but it still does not work.

The modified script:

function listFilesInFolder(folderName) {
//writes the headers for the spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Image"]);
var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";

var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();

var cnt = 0;
var file;

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

    Logger.log(file);
    Logger.log(cnt);
    // writes the various chunks to the spreadsheet- just delete anything you don't want
        data = [
           
            "https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
            file.getDescription(),
            "=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
        ];

        sheet.appendRow(data);
};
};

The spreadsheet

Google drive folder Scripts

edited tags
Link
General cleanup (language/layout)
Source Link

I have an image in a folder that iI want to get inimport into my spreadsheet  (image inin a cell). AmI'm using the script from:

  Insert image from Google Drive into Google Sheets (little modifiedwith some modifications).

But i tried this and it do only workworks on one of the images, how can i fix it?.

Tips, i canI could see that the other imagesimage is at pnga .png and the onlyfirst image is jpg that goes in but i have trydwas a .jpg. I tried to convert one png image to jpg andthe .png into .jpg, but it still dosedoes not work.

The modified script:

function listFilesInFolder(folderName) { //writes the headers for the spreadsheet var sheet = SpreadsheetApp.getActiveSheet(); sheet.appendRow(["Image"]); var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";

function listFilesInFolder(folderName) {
//writes the headers for the spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Image"]);
var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";

var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();

var cnt = 0;
var file;

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

    Logger.log(file);
    Logger.log(cnt);

// writes the various chunks to the spreadsheet- just delete anything you don't want data = [

    // writes the various chunks to the spreadsheet- just delete anything you don't want
        data = [
           
            "https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
            file.getDescription(),
            "=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
        ];

        sheet.appendRow(data);
 
    
};
};

};

The spreadsheet

Google drive folder Scripts

I have image in a folder that i want to get in my spreadsheet(image in a cell). Am using the script from:

Insert image from Google Drive into Google Sheets (little modified)

But i tried this and it do only work on one of the images, how can i fix it?

Tips, i can see that the other images is at png and the only image is jpg that goes in but i have tryd to convert one png image to jpg and it still dose not work.

The modified script:

function listFilesInFolder(folderName) { //writes the headers for the spreadsheet var sheet = SpreadsheetApp.getActiveSheet(); sheet.appendRow(["Image"]); var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";

var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();

var cnt = 0;
var file;

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

    Logger.log(file);
    Logger.log(cnt);

// writes the various chunks to the spreadsheet- just delete anything you don't want data = [

            "https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
            file.getDescription(),
            "=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
        ];

        sheet.appendRow(data);
 
    

};

};

The spreadsheet

Google drive folder Scripts

I have an image in a folder that I want to import into my spreadsheet  (in a cell). I'm using the script from  Insert image from Google Drive into Google Sheets (with some modifications).

But this only works on one of the images.

I could see that the other image is a .png and the first image was a .jpg. I tried to convert the .png into .jpg, but it still does not work.

The modified script:

function listFilesInFolder(folderName) {
//writes the headers for the spreadsheet
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Image"]);
var folderId = "1smphWTohvgOVTwGDbxrIxsFWeFd3tBNo";

var folder = DriveApp.getFolderById(folderId);
var contents = folder.getFiles();

var cnt = 0;
var file;

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

    Logger.log(file);
    Logger.log(cnt);
    // writes the various chunks to the spreadsheet- just delete anything you don't want
        data = [
           
            "https://docs.google.com/uc?export=download&confirm=no_antivirus&id=" + file.getId(),
            file.getDescription(),
            "=image(\"https://docs.google.com/uc?export=download&id=" + file.getId() +"\")",
        ];

        sheet.appendRow(data);
};
};

The spreadsheet

Google drive folder Scripts

Source Link
Loading