cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Add image in to excel table from base64

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 🙏

2 ACCEPTED SOLUTIONS

Accepted Solutions

@Anonymous  thanks my friend, it's a pleasure to help here.

 


@Anonymous wrote:

The need is to insert image in excel's Image(Optional) column. This is required.

 



It's a shame but unfortunally we can't do this with PA this is not supported yet.

 

And to answe your second question see it's in profile setting

ignature.PNG

 

I don't know if this is available for all users but is there jejeje



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me:
Youtube: Christian Abata
Facebook: Power Automate LA
Power Automate examples: Power Automate examples

View solution in original post

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

View solution in original post

19 REPLIES 19
fchopo
Super User
Super User

Hello @Anonymous 

Could you try to convert your base64 image to binary and send it to excel by using dataUriToBinary() function?

Have a look at this thread: https://powerusers.microsoft.com/t5/Building-Power-Apps/PowerApps-to-Flow-DataURIToBinary/td-p/156177

Hope it helps!

Ferran

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
Anonymous
Not applicable

Hi @fchopo ,

I have tried with the reference article you mentioned but it is giving following error-Excel Connector

 

InvalidTemplate. Unable to process template language expressions in action 'Add_a_row_into_a_table' inputs at line '1' and column '2784': 'The template language function 'dataUriToBinary' expects one parameter: the data URI that is to be converted to binary. The function was invoked with '0' parameters. Please see https://aka.ms/logicexpressions#dataUriToBinary for usage details.'.

 

 

 The function is

 

dataUriToBinary(items('Apply_to_each')['p5'])

 

Anonymous
Not applicable

With the help of JSON parse connector, successfully converted image data URI to binary and updated in cell of table.

But in cell it shows something like ?PNG

So should I conclude that images can't be inserted to excel via flows.

Anonymous
Not applicable

@ChristianAbata Hi, Can you help in this regard?

hi @Anonymous  shure. 

 

So if you want something like this

make.PNG

 

I'm afraid my friend is not possible with PA, because and image is not part of a excel row, and image is like a frame inside excel, and until today this is not suppported by PA.

 

Another scenario is this

this.PNG

 

inserting data in base64 into excel to use it in Power Apps and show images by reading the data in excel.

Please let me know what scenario you are needing.



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me:
Youtube: Christian Abata
Facebook: Power Automate LA
Power Automate examples: Power Automate examples

@ChristianAbata 

First of all I would like to congratulate you for being elevated as Super User 🎉🎉🎉

 

When user fills and submits information from PowerApps, a new item will be created in SPO list.

Then a flow will be triggered which will first parse JSON from PayLoad1, PayLoad2, PayLoad3 of SPO list item.

Then excel's Add Rows connector will fill up three tables from above data in a existing excel templete.

Excel sheet has 3 Tables(Table1,Table2,Table3).

 

All 3 tables' column names are same- SrNo, Area, Point, Status, Remark, Image(Optional). (Total 6 columns & 3 tables)

Then an email will be sent attaching that excel file to preset user email addresses.

After that all rows from all 3 tables will be deleted using another excel connector.(To make it ready for future flow trigger as a template).

Everything is running fine except image inserting issue in excel excel sheet table.

 

The need is to insert image in excel's Image(Optional) column. This is required.

 

(Off the topic question: How can I create my signature so that it added automatically when creating/replying to a post in this community forum? just like like outlook has that feature)

 

 

Best Regards,

Ankit Shah

Surat-India

Twitter: https://twitter.com/AnkitShah55

@Anonymous  thanks my friend, it's a pleasure to help here.

 


@Anonymous wrote:

The need is to insert image in excel's Image(Optional) column. This is required.

 



It's a shame but unfortunally we can't do this with PA this is not supported yet.

 

And to answe your second question see it's in profile setting

ignature.PNG

 

I don't know if this is available for all users but is there jejeje



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me:
Youtube: Christian Abata
Facebook: Power Automate LA
Power Automate examples: Power Automate examples

@ChristianAbata 

Thanks friend for clarifying that, now I have no doubts and I can move forward.

What I am thinking to create a zip file containing that excel file and image files.

Every image file name will be copied to ImageName column in excel table.

 

Is this good practice? Or if you have idea?

(PS: I am convincing my senior to generate reports in PDF instead of excel, I can do it by using HTML)

@Anonymous  excellent way my friend. You can create .rar file and then in excel add the url to that file.

 

Pd: If you can convince your superior to use pdf is better, because as you said you can use HTML, I don't know if you saw this video but I give you anyway https://www.youtube.com/watch?v=2rfAQe1kK8M, is a Shane Video



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me:
Youtube: Christian Abata
Facebook: Power Automate LA
Power Automate examples: Power Automate examples

@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 👋

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



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me:
Youtube: Christian Abata
Facebook: Power Automate LA
Power Automate examples: Power Automate examples

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

Ganeshkumar_R
Frequent Visitor

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

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.

Eulopezp
Frequent Visitor

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 @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

 

@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.

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? 

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

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (953)