Modern SharePoint Web Parts: Document Library and File Viewer

In this third article of our series on Modern SharePoint Web Parts, we’re covering the Document Library and File Viewer web parts. These two web parts, either alone or in combination, give people visibility into files stored within SharePoint libraries.

Document Library Web Part

image

The Document library web part allows you to select a single library within the current SharePoint site, from which to display contents. The web part will display the name of the document library at the top, but you as the page designer can name the web part whatever you choose by typing into the title area.

Selecting a SharePoint document library to display in the web part
Select a SharePoint Document library

In the resulting web part display, any column formatting or folders will be displayed as they are within the library. People can use the column headers to sort, group, and filter files as they would within the library itself.

image

Users can also switch to a Compact List or to a Tiles display.

image

Note that any settings you change within the web part do not affect the underlying library views and do not persist when your page reloads, unless you save the changes. A user can also click on the See All link within the web part, to open the underlying library, though be aware that it opens on the same tab unless the user right-clicks and chooses to open in a new tab.

Users with the appropriate permissions can also create and upload files in the library from within the web part, sync files, and export to Excel. And when a file is selected, users can download, rename, or delete the file, or pin it to the top. This gives a fairly robust experience on the page. However, there are some command bar actions which are not (as of this writing) supported in the Document Library Web Part: flows, alerts, share/link, copy/move, version history, and check out/in.

If the selected library has multiple Views created within SharePoint, then in the web part’s edit pane you can select one of those views to display by default in this web part instance. You can also choose to display only a specific folder in this web part instance. In addition, there are four Size options: Autosize, to size the web part to display all items in the library, or Small (5 items), Medium (15 items), or Large (30 items). There is also an option to Show (default) or Hide the command bar, in case you would prefer users not be able to manage the files or views.

image

File Viewer Web Part

image

As you might expect, the File Viewer Web Part allows you to display a file on the page. It was formerly called the Document Web Part; however, now this web part will allow previews of a number of file types, so it’s no longer just for documents. Besides displaying Office documents (i.e. Word, Excel, PowerPoint), you can also display PDFs, 3D models, and more. Note that image files are not supported, as there is a separate Image Web Part – we’ll cover that in a later article. And many other file types (such as dwg files) are not yet supported in the File Viewer web part, though the list is growing. Unsupported file types will simply not be available during the file selection step.

After adding this web part, you are immediately prompted to select a file from either a list of recent documents, OneDrive, a document library on the current site, a new upload (which will automatically go into the site’s built-in Documents library), or a link. Note that if you later click on Change File, you no longer see the Upload option.

image

You can add a description below the document, similar to a caption.

image

The document will be embedded on the page, and users can page or scroll through it directly from there. Options to configure the web part vary by the document type. For example, if it’s a PowerPoint presentation, you can select which slide should be displayed first. For a Word or PDF document, you can select the start page. If it’s an Excel workbook, there are additional display options:

image

After the page is saved, users will have access to a menu allowing them to download or print the document, among other things.

image

Dynamic Data Connections

As described above, the File Viewer web part is a static display of a single file which you have selected. However, fairly recently support has been added for dynamically selecting a file to display, based on a selection made in the Document Library web part. We wrote about this feature a few months ago in SharePoint Online Web Part Connections. Take a look at that article for a walkthrough on connecting a Document Library web part to a File Viewer web part. Essentially it involves using the Connect to Source option in the File Viewer Web Part to connect it to a Document Library web part.

image

image

Note that although Microsoft states that images are not supported in the File Viewer, and image files are not listed among files from which you can select when configuring a File Viewer statically, when you connect it to a Document Library web part, it will indeed show a preview of an image file that has been selected.

So with the configuration options we’ve outlined, and the ability to connect these two web parts, you can create a SharePoint page which lists and previews the documents you wish to show from the current site. If you find yourself wishing you could list files from multiple libraries and from other sites, you may want to look at our Lightning Conductor content rollup web part (for files from multiple sites and libraries), or our Data Viewer web part (for a single library from another site).

Related Posts
Clear Filters

Add Comment