web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / import an image to exc...
Power Automate
Answered

import an image to excel by script through power automate

(0) ShareShare
ReportReport
Posted on by 19

Hi All

I am trying to use the script to get an image from the SharePoint to the excel.  However I only get a bunch of characters like this after running the flow 

Problematic_3-1651646323083.png

the intended design should be like this

Problematic_4-1651646439186.png

I  can get the file content of the image by using base64 function  

Problematic_1-1651645936412.png

Problematic_2-1651645978135.png

In the excel script, what I wrote : 

Interface Answer {

chop : string;

}   *(This is one of the steps to get the image file from the SharePoint list after the user input the required data to pull out)

let picture = selectedSheet.addImage(answer.chop);

picture.setTop(950);

picture.setLeft(440):

 

Can anyone  advise why I only get a bunch of characters instead of an image.  How to make the correct statement to import the image

 

Thanks in advance.

 

Categories:
  • Yutao Huang Profile Picture
    Microsoft Employee on at

    This flow and script worked for me:

    Yutao_0-1652466134622.png

     

    function main(workbook: ExcelScript.Workbook, imageBase64: string)
    {
     let picture = workbook.getWorksheet("Sheet5").addImage(imageBase64);
     picture.setTop(30);
     picture.setLeft(30);
    }

     

    And the result:

    Yutao_1-1652466201072.png

     

    Do you mind sharing a bit more of your flow?

     

  • Problematic Profile Picture
    19 on at

    Thanks a lot.  It works.

     

    However, I have another issue.   After adding the image to the excel and send this excel worksheet out by email, how can I remove the image from the excel as this excel is served as the master template.  I wrote a new script for the image deletion as follows :

    This is what I wrote :

    Problematic_0-1652494383232.png

    how can I define the variable as the image added from previous script would be different everytime

     

    Problematic_1-1652494499765.png

     

     

  • Verified answer
    Yutao Huang Profile Picture
    Microsoft Employee on at

    You can give the image a name (with the setName API) after adding it to the worksheet:

     

    function main(workbook: ExcelScript.Workbook, imageBase64: string)
    {
     let picture = workbook.getWorksheet("Sheet5").addImage(imageBase64);
     picture.setName("image-name");
     picture.setTop(30);
     picture.setLeft(30);
    }

     

     

    And later in the script to delete the image:

     

    function main(workbook: ExcelScript.Workbook) {
     let picture = workbook.getWorksheet("Sheet5").getShape("image-name");
     picture.delete();
    }

     

     

    Please note that image is a special type of shape in Excel, so you'll need to use getShape() to find it.

  • Problematic Profile Picture
    19 on at

    HI Yutao

     

    Appreciate your support and thanks a lot. 

  • robert111111 Profile Picture
    4 on at

    not working on me.. please help.. i did everything but no use

     

    robert111111_0-1690897960576.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 430

#2
11manish Profile Picture

11manish 341 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 282

Last 30 days Overall leaderboard