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
the intended design should be like this
I can get the file content of the image by using base64 function
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.
Solved! Go to Solution.
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.
This flow and script worked for me:
function main(workbook: ExcelScript.Workbook, imageBase64: string)
{
let picture = workbook.getWorksheet("Sheet5").addImage(imageBase64);
picture.setTop(30);
picture.setLeft(30);
}
And the result:
Do you mind sharing a bit more of your flow?
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 :
how can I define the variable as the image added from previous script would be different everytime
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.
HI Yutao
Appreciate your support and thanks a lot.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
12 | |
11 | |
9 | |
9 | |
6 |
User | Count |
---|---|
26 | |
20 | |
12 | |
9 | |
7 |