PROBLEM: The user creates a flow that saves files to a SharePoint document library, but the files cannot be opened.
This is a question that I am starting to see more often than I would like. The user creates a flow that saves files to a SharePoint document library, but the files cannot not be opened. What’s really strange is that the same actions work fine in other flows.
QUESTION
I have built a Flow that automatically uploads Excel email attachments to a SharePoint library. The Flow runs successfully, and appears to be okay, however I am unable to open the files from SharePoint (both web version and desktop version). Does anyone have any idea?
See: Forum Post #1: Uploading Excel email attachments to SharePoint library and Forum Post #2: Attachment excel to SharePoint malformed

This Flow should work
The following flow saves email attachments to a SharePoint document library (step 4):

⚠️ But in some rare instances users have reported that saved files cannot be opened.

It seems as if the information about the file type has been lost (i.e. Is the file an image, Word document or an Excel worksheet?) .
✅ The workaround for this issue
A workaround for this issue is to use a compose action to store the file content type and file content:
{
"$content-type": <contentType>,
"$content": <contentBytes>
}
Then use the output of the compose action as the File Content in the SharePoint Create file action:

❌ Testing by REMOVING the content-type information
If I remove the “$content-type” property from the Compose action I get the same error: “Couldn’t Open the Workbook”


It does seem that the information about file type has been lost (i.e. Is the file an image, Word document or an Excel worksheet?) . The examples I have so far seen affect Excel files, but it’s unclear if the issue affects other file types as well.
Leave a Reply