How to Fix Base64 Images Not Inserting into Excel via Office Scripts
Question details
The user needs to insert Base64 signature images originating from Power Apps into an Excel worksheet via Office Scripts and Power Automate.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Transferring Base64 image strings from Power Apps to Excel using Power Automate and Office Scripts.
- Observed behavior
- The Base64 image fails to insert into the worksheet when passed directly through Power Automate, even though hardcoded Base64 strings work perfectly in the script.
Ensure you have access to both the Power Automate flow and the target Excel file. Verify that the Base64 string generated by Power Apps is complete and not corrupted before sending it to Excel.
Store Base64 Strings in a Hidden Worksheet
Bypass direct parameter passing limitations by writing the Base64 string to a cell first, then retrieving it within the Office Script.
Passing extremely long Base64 strings as direct parameters from Power Automate to an Office Script can sometimes cause formatting or truncation issues. Storing the string in a temporary Excel cell acts as a reliable bridge for the data.
Modify your flow to write the Base64 string into a specific cell (e.g., A1) on a hidden or temporary worksheet, instead of passing it as a parameter in the 'Run script' action.
Use the getRange().getText() method to retrieve the Base64 string from the temporary cell within your script. For example: let base64String = workbook.getWorksheet('TempSheet').getRange('A1').getText();
Pass the retrieved text string into the addImage() method to render the image on the desired worksheet.
Add a final step in your script to clear the contents of the temporary cell using getRange().clear() after the image is successfully inserted.

Inspect Run Script Inputs for Data Truncation
Verify if Power Automate is incorrectly formatting or truncating the Base64 string during the transfer process.
Looking for a simpler way to automate spreadsheets? Try WPS Office
If complex Power Automate flows and cloud-based Office Scripts are causing workflow bottlenecks, consider WPS Office. It offers a powerful built-in JS Macro editor and excellent VBA compatibility for automating spreadsheet tasks without relying on external cloud connectors.
- 1. Download and Install WPS Office: Get the free WPS Office suite from the official website and install it on your computer.
- 2. Open Your Spreadsheet: Launch WPS Spreadsheet and open your existing .xlsx files with full format retention.
- 3. Access the Macro Editor: Navigate to the 'Tools' tab and click on 'Macros' or 'JS Macro' to write and execute your automation scripts locally.

Frequently Asked Questions
Why does my Office Script work with a hardcoded Base64 string but fail in Power Automate?
Power Automate may truncate or improperly escape extremely long Base64 strings when passing them directly as script parameters. Storing the string in an Excel cell first circumvents this cloud-transfer limitation.
Do I need to include the data URI prefix (e.g., data:image/png;base64,) in my string?
No, the addImage() method in Office Scripts generally expects only the raw Base64 string data. Ensure you strip the data URI prefix before passing the string to the script.
How can I hide the worksheet used for transferring Base64 data?
You can manually right-click the worksheet tab in Excel and select 'Hide', or you can use an Office Script command like workbook.getWorksheet('Temp').setVisibility(ExcelScript.SheetVisibility.hidden); to keep it hidden automatically.




