Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Add image in to excel table from base64

(0) ShareShare
ReportReport
Posted on by

Hi,

Scenario

SPO list "Covid19_Compliance" has 3 column names 'PayLoad01', 'PayLoad02', 'PayLoad03'.

The data in these columns contains stringified JSON of user inputs which includes Texts, Camera captured images(base64).

SPO list is updated from PowerApps.

 

The Problem:

I am able to add all data from those columns into excel tables using Parse JSON & Excel Business connector.

But I am unaware how to add base64 encoded images into cell of excel table.

Also suggest me if I need to make changes at PowerApps level, like some alternatives instead of converting images to base64.

I need help 🙏

  • MarkAnthony_ Profile Picture
    8 on at
    Re: Add image in to excel table from base64

    Hi! Do you still have the codes and flow's steps?

  • LucaNeedsHelp Profile Picture
    207 on at
    Re: Add image in to excel table from base64

    Hello, i get always a new image from the MS Forms in my OneDrive. Is it possible to get this images also in the excel? 

  • Yutao Huang Profile Picture
    Microsoft Employee on at
    Re: Add image in to excel table from base64

    @RameshMukka - to properly align an image to a range, you will need to specify the image's top, left, width, and height to match with the respective top, left, width, and height of the target range.

     

    For example, in order to achieve the same result in this screenshot:

    Yutao_0-1695918409097.png

     

    You can write your script like this:

    function main(workbook: ExcelScript.Workbook) {
     const base64ImageString1 = "iVBORw0KGgoAAAANSU...";
     const base64ImageString2 = "iVBORw0KGgoAAAANSU...";
     const sheet = workbook.getWorksheet("Sheet6");
     const range1 = sheet.getRange("B2");
     const image1 = sheet.addImage(base64ImageString1);
     image1.setTop(range1.getTop());
     image1.setLeft(range1.getLeft());
     image1.setWidth(range1.getWidth());
     image1.setHeight(range1.getHeight());
     image1.setPlacement(ExcelScript.Placement.twoCell);
    
     const range2 = sheet.getRange("B4:E6");
     const image2 = sheet.addImage(base64ImageString2);
     image2.setTop(range2.getTop());
     image2.setLeft(range2.getLeft());
     image2.setWidth(range2.getWidth());
     image2.setHeight(range2.getHeight());
     image2.setPlacement(ExcelScript.Placement.twoCell);
    }

     

    Using `ExcelScript.Placement.twoCell` can make sure Excel will automatically move and resize an image when you move and resize the range below it.

  • rameshmukka Profile Picture
    1,091 on at
    Re: Add image in to excel table from base64

    @Eulopezp @Yutao 

    The script works great and images are show in excel. However the images are not aligned in the excel rows and they overlapped over other. How do I fit the images in the column designated for the image. Is it even possible to fit in the image in the cell of image column?

    RameshMukka_0-1694842914465.png

     

  • Eulopezp Profile Picture
    on at
    Re: Add image in to excel table from base64

    The problem was solved, it is needed to remove the "data:image/jpeg;base64,".

    This is a very common problem in Power Apps, just in case someone get it 🙂

  • Eulopezp Profile Picture
    on at
    Re: Add image in to excel table from base64

    Hi @Yutao ,

    This is not working for me, I get the following error:flow.png

     

    This is the excel file: 

    excel.png

     

    Any ideas about what could be wrong?

     

    Thanks in advance,

    Eugenio.

  • Ganeshkumar_R Profile Picture
    20 on at
    Re: Add image in to excel table from base64

    Guys,

     

    Can you explain how we can add in this below format

    Ganeshkumar_R_0-1610367274775.png

    @ChristianAbata  - Need to take the SharePoint attachment content and add that in excel table which is in OneDrive. I can able to take the attachment content using get attachment and get attachment content action from SharePoint. By passing the value to Update Row action is not working. Can anyone help this out it emergency 

     

    Thanks

  • Verified answer
    Yutao Huang Profile Picture
    Microsoft Employee on at
    Re: Add image in to excel table from base64

    Hey friends,

     

    Wondering if you'd like to try out the new "Run script" action of Excel Online (Business), where you can actually run Office Scripts to:

    • Retrieve images from Excel as base64 encoded content then pass to the next action in Power Automate
    • Or pass in some base64 encoded image content to create an image in Excel

     

    For example, this is an action to add an image (encoded in base64) to cell "E8" on "Sheet1" in Excel:

    flow-run-script-add-image.png

     

     

    You'll need to first create the "Add image" script in Excel Online. Here is one sample script that can be used here:

     

    function main(workbook: ExcelScript.Workbook, sheetName: string, address: string, base64ImageString: string) {
     let sheet = workbook.getWorksheet(sheetName);
     let range = sheet.getRange(address);
     let image = sheet.addImage(base64ImageString);
     image.setTop(range.getTop());
     image.setLeft(range.getLeft());
    }

     

     

    Here are a few links that might be helpful to learn more about the new Run script action and Office Scripts:

     

    And a few Office Scripts APIs that might be helpful here:

     

    Hope this helps!

    Yutao

  • ChristianAbata Profile Picture
    8,947 Most Valuable Professional on at
    Re: Add image in to excel table from base64

    @Anonymous  you are welcome my friend. Please consider to mark an answer as solutions to guide other over your question 😉

  • Community Power Platform Member Profile Picture
    on at
    Re: Add image in to excel table from base64

    @ChristianAbata Yes I have watched that video, in fact I follow all videos and updates from Shane, (He is like a guru)

    Well, Thanks for all help friend 👋

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >