How can I upload an image from google sheet to slides

22 views Asked by At

I am tryng to import a data from google sheets to slides. I have the code below however, im having a hard time converting the link into an exact image when it is imported to slides.

Here is the code I have and I couldnt figure out how to upload it as an image instead of a link:

function createOneSlidePerRow() {

  // Replace <INSERT_SLIDE_DECK_ID> wih the ID of your 
  // Google Slides presentation.
  let masterDeckID = "14VmhMKlUSoqah4K3C7mSr4B8q-p_govoMl9QAGBc1c4";

  // Open the presentation and get the slides in it.
  let deck = SlidesApp.openById(masterDeckID);
  let slides = deck.getSlides();

  // The 2nd slide is the template that will be duplicated
  // once per row in the spreadsheet.
  let masterSlide = slides[1];

  // Load data from the spreadsheet.
  let dataRange = SpreadsheetApp.getActive().getDataRange();
  let sheetContents = dataRange.getValues();

  // Save the header in a variable called header
  let header = sheetContents.shift();

  // Create an array to save the data to be written back to the sheet.
  // We'll use this array to save links to the slides that are created.
  let updatedContents = [];

  // Reverse the order of rows because new slides will
  // be inserted at the top. Without this, the order of slides
  // will be the inverse of the ordering of rows in the sheet. 
  sheetContents.reverse();

  // For every row, create a new slide by duplicating the master slide
  // and replace the template variables with data from that row.
  sheetContents.forEach(function (row) {

    // Insert a new slide by duplicating the master slide.
    let slide = masterSlide.duplicate();

    // Populate data in the slide that was created
    slide.replaceAllText("{{Timestamp}}", row[0]);
    slide.replaceAllText("{{SKU}}", row[1]);
    slide.replaceAllText("{{Factory}}", row[2]);
    slide.replaceAllText("{{ BP Order #}}", row[3]);
    slide.replaceAllText("{{Defect Description}}", row[4]);
    slide.replaceAllText("{{Reamaze Conversation}}", row[5]);
    slide.replaceAllText("{{Upload Image}}", row [6]);
    slide.replaceAllText("{{Item cost}}", row [7]);
    slide.replaceAllText("{{Replacement cost}}", row [8]);
}

This code works but i dont know how to convert it to an image when it is imported to slides.

0

There are 0 answers