#PowerPlatformTip 132: 'Office Files Viewer in PowerApps'
TL;DR: Power Apps has no Office viewer control, but a SharePoint document library already delivers a preview for every file:
ThisItem.Thumbnail.Large. Put it in an Image control for an instant preview, swap the URL to the PDF rendition for Word, Excel and PowerPoint in a PDF viewer, and open the full document withLaunch(ThisItem.'Link to item'). Standard SharePoint connector, no flow.
Users want to glance at a contract, a protocol or a price list without leaving the app. A canvas app can’t embed Word or Excel directly, yet SharePoint renders previews of these files anyway. You only need to show what SharePoint already produces.
💡 Challenge
There is no control that displays .docx, .xlsx or .pptx in a canvas app. The PDF viewer only shows PDFs, and an Image control only shows images. Downloading the file or building a flow for every preview is slow and clumsy.
✅ Solution
Use the Thumbnail column that the SharePoint connector returns for every file in a document library. Its Large URL is a rendered image of the first page, it works for Office files, PDFs and images, and it loads directly in an Image control. For a multi-page view of Office files, the same rendering service also returns a PDF version, which the PDF viewer can display.
🔧 How It’s Done
1. Connect the document library
🔸 Add the SharePoint document library as a data source and add a vertical gallery with Items set to the library, for example Documents.
🔸 Gallery OnSelect: Set(varSelectedFile, ThisItem)
2. Show the preview
🔸 Add an Image control next to the gallery:
1
varSelectedFile.Thumbnail.Large
🔸 The thumbnail shows the first page of Word, Excel, PowerPoint and PDF files, and the picture itself for image files. Inside the gallery, ThisItem.Thumbnail.Small gives you a file icon-sized preview per row.
3. Optional: show Office files page by page
🔸 Add a PDF viewer control and set Document:
1
2
3
4
If(
Lower(Last(Split(varSelectedFile.'File name with extension', ".")).Value) in ["docx", "xlsx", "pptx"],
Substitute(varSelectedFile.Thumbnail.Large, "/thumbnail", "/pdf")
)
🔸 The thumbnail URL points to SharePoint’s rendering service. Replacing /thumbnail with /pdf asks the same service for a PDF rendition of the whole document. This URL pattern is not a documented API, so treat it as a convenience: if the PDF viewer stays empty, the Image preview from step 2 still works.
🔸 Make the controls visible by file type, for example PDF viewer Visible: !IsBlank(Self.Document) and Image Visible: !PDFViewer1.Visible.
4. Open the original
🔸 Add a button Open with OnSelect:
1
Launch(varSelectedFile.'Link to item')
🔸 The document opens in the browser, where the user can read the whole file or edit it.
🎉 Result
Users pick a file in the gallery and see its preview right away, Office files can be read page by page in the PDF viewer, and one click opens the original. All of it runs on the standard SharePoint connector without a flow.
🌟 Key Advantages
🔸 No premium: the SharePoint connector is a standard connector.
🔸 No flow: the previews come straight from SharePoint, so there is no extra run and no waiting.
🔸 Many file types: one Image control covers Office files, PDFs and images.
🔸 Permissions stay intact: users only see files they are allowed to open in SharePoint.
⚠️ Good to Know
🔸 Thumbnails are images. For documents you get the first page. Use the PDF viewer or Launch() for the full content.
🔸 Resolution: the large thumbnail is rendered at about 800 x 800 pixels and looks soft on a big Image control. Keep the control at that size or use the PDF route.
🔸 PDF files are left out of the formula in step 3 because they need no rendition. Show them with the download.aspx URL from the PDF Viewer post linked below, or with the thumbnail preview plus Launch().
🔸 List attachments are not library files and have no Thumbnail column. For those, Reza Dorrani’s ready-made Attachments Viewer component combines Image, PDF viewer and Video controls.
🛠️ FAQ
1. Which file types show a preview?
Word, Excel, PowerPoint, PDF and common image formats get a rendered thumbnail. For other types SharePoint returns a generic icon or nothing, so plan a fallback text such as “No preview, open the file”.
2. Do I need Power Automate?
No. Thumbnail, PDF rendition and Launch() work without a flow.
3. Why is the Image control empty for a file?
The file is either brand new (SharePoint renders the thumbnail a moment after upload) or its type has no preview. Refresh the data source after a few seconds or show the fallback text.
🔗 Related Tips
- #PowerPlatformTip 159: Force a Direct File Download in Power Apps with Launch, when users should download the file instead of viewing it.
- Power Apps PDF Viewer for a SharePoint Document Library, the PDF-only variant of this viewer.
- #PowerPlatformTip 92: Free PDF Tools in Power Automate, generate and manipulate PDFs for viewing.
This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).