@Anonymous
After further investigation into the requirement, checked the flow to see if we read the images from Excel. None of the flow actions supports this directly or indirectly.
Then, started checking for workarounds.
When we save an excel file with images as html, then we can see all the images in excel file saves in a folder along with an xml file with the list of files and also every worksheet will have one Sheet1.html file. This file will contain the image content in binary/base64. Unfortunately, saving as html and parsing thru these files is custom dev work and cannot be done from flow. Write a C#, Python or some other way.
Another workaround: In the Excel, write a macro to read the images as Shapes, save them in local directory and convert them to either base64 or binary.
I am not VBA expert but i am able to manage to show the base64 code in a message box. You can update the code in the column next to the image and this code can be read from the flow.
Here is the Macro's VBA Code for your reference:
Public Function convertImageToBase64(filePath) Dim inputStream Set inputStream = CreateObject("ADODB.Stream") inputStream.Open inputStream.Type = 1 ' adTypeBinary inputStream.LoadFromFile filePath Dim bytes: bytes = inputStream.Read Dim dom: Set dom = CreateObject("Microsoft.XMLDOM") Dim elem: Set elem = dom.createElement("tmp") elem.DataType = "bin.base64" elem.nodeTypedValue = bytes convertImageToBase64 = "data:image/png;base64," & Replace(elem.Text, vbLf, "") End Function Sub ConvertToBase64() Dim ch As Chart Set ch = Charts.Add ch.Location xlLocationAsObject, "sheet1" Set ch = ActiveChart Dim sh As Shape For Each sh In ActiveSheet.Shapes sh.CopyPicture ActiveSheet.ChartObjects(1).Width = sh.Width ActiveSheet.ChartObjects(1).Height = sh.Height
ch.Paste
filePath = "C:\Users\xxxx\Documents\Demo\" & sh.Name & ".png" ch.Export filePath
base64Code = convertImageToBase64(filePath)
MsgBox base64Code Next sh End Sub |
After speaking with a friend, I came to know that the For Each loop in the above function may not read the images in the same order. For that, in the VBA code, we need to read the co-ordinates of the cell and then get the image. I did not try this. Also, most of the companies may not allow Macros in the excel due to security concerns. We may need to try alternate work around such as creating an Azure Functions to read excel content. This requires custom coding. Once the Azure function is ready, we can call them from Power Automate actions. I hope Microsoft will provide an appropriate action to read images. Keeping maintainability or support of technical solutions will be challenge if the solution is complex. I recommend to store the data in SharePoint list or similar way which Power Automate supports if business is convinced to use it. All the best. Regards Krishna Rachakonda | If this reply helped you to solve the issue, please mark the post as Accepted Solution. Marking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone. |
|