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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Power Up Program Community
Unanswered

Script to convert base64 to image in Excel not working

(1) ShareShare
ReportReport
Posted on by 104
I have developed a mobile power app for my engineers to complete treatment reports in the field and capture signatures.
 
I created a flow to retrieve the report information and signature images from the app and upload them to a Sharepoint list + doc library. All of this work perfectly.
 
I also want to output the captured information (+signatures) in a template that can be converted to PDF and given to the customer.
 
The problem I'm having is that the flow fails on the script when trying to add the image to the excel worksheet. I am confused as I mostly plagiarised the script from this thread, where it has worked perfectly for others, and I know the (two) base64 string(s) to be correct, as i've run it through an online converter, which outputs images of the signatures that were originally captured.
 
 
 
 
This suggests the problem lies in line 6 of the script. Unfortunately, I'm not an expert, and the last time i played with Excel scripts was over a decade ago with VBA rather than Office Scripts. I have tried playing with it in as far as i can, but nothing seems to offer any success. To me, the script actually appears fine, and it seemingly worked for others according to the other thread. As the base64 script is correct (and doesn't include the data: or /png etc), I'm left bewildered and hoping that someone can spot where i've gone wrong (that person will have my eternal gratitude!). Script included below
 
 
function main(workbook: ExcelScript.Workbook, base64ImageString1:string, base64ImageString2:string) 
{
   const sheet = workbook.getWorksheet("Output");
   const range1 = sheet.getRange("C43");
   const range2 = sheet.getRange("I43");   
   let 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);
   let 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);
}
 
Categories:
I have the same question (0)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Microsoft Power Up Program Community

#1
timl Profile Picture

timl 512 Super User 2025 Season 2

#2
mmbr1606 Profile Picture

mmbr1606 62 Super User 2025 Season 2

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 60 Super User 2025 Season 2

Last 30 days Overall leaderboard