As a SharePoint site owner, you may need a complete list of files in a document library for auditing, migration planning, or storage reporting. Manually copying file names and metadata is slow and error-prone. SharePoint provides several built-in methods to export library data to a CSV file without third-party tools. This article walks through each method, explains what data you can capture, and lists common pitfalls to avoid.
Key Takeaways: How to Export a SharePoint Library to CSV
- Export to Excel from the library ribbon: Quickest method for up to 5,000 items with default columns.
- Create a view and export it: Use a custom view to filter or sort files before exporting the data.
- PowerShell with PnP.PowerShell: Export unlimited items and include metadata columns not shown in the default view.
What You Can Export From a SharePoint Document Library
A SharePoint document library stores files plus metadata columns such as Created By, Modified Date, File Size, and custom columns like Document Type or Project Name. When you export the library to CSV, you can capture all visible columns in the current view. The export process creates a .csv file that opens in Excel or any spreadsheet application. You cannot export file contents or version history directly to CSV — only the metadata rows. If you need version history, use the built-in Version History report or a PowerShell script.
Before you start, confirm you have at least Edit or Contribute permissions on the library. Site members with Read access can view files but cannot export the library list data. If the library contains more than 5,000 items, the standard export may time out. Use the PowerShell method for large libraries.
Method 1: Export to Excel From the Library Ribbon
This is the fastest way to export a library inventory. It works for libraries with fewer than 5,000 items and exports all columns visible in the current view.
- Open the document library
Navigate to the SharePoint site and open the document library you want to export. - Click Export to Excel
In the library toolbar, select Export then Export to Excel. If the option is missing, your browser may block pop-ups — allow pop-ups for the SharePoint domain. - Confirm the export query
A dialog asks if you want to export the current view. Click Open or Save. The file downloads as an .iqy file, which Excel opens as a linked table. - Save as CSV
In Excel, go to File > Save As, choose CSV UTF-8 (Comma delimited), and name the file. The CSV now contains all rows and columns from the library view.
Method 2: Create a Custom View and Export
Use this method when you need only specific files or columns. Create a view that filters or sorts the library, then export that view to CSV.
- Create a new view
In the library, click All Items (or the current view name) and select Create new view. Choose a view type such as Standard View. - Set filters and columns
Name the view. Under Columns, select only the columns you need. Under Filter, add conditions like File Type equals pdf or Modified is greater than 1/1/2024. Click OK. - Export the new view
Switch to the view you created. Follow the same steps as Method 1: Export > Export to Excel. The exported data matches only the files and columns visible in this view. - Delete the view if not needed
After export, you can delete the temporary view from Library Settings > Views to keep the library clean.
Method 3: Export With PowerShell (PnP.PowerShell)
PowerShell is the only built-in method that handles libraries with thousands of items and can export metadata columns not visible in the default view. You need the PnP.PowerShell module installed on your computer and SharePoint admin or site owner permissions.
- Install PnP.PowerShell
Open PowerShell as administrator and run:Install-Module PnP.PowerShell -Scope CurrentUser. Answer Yes to install from PSGallery if prompted. - Connect to your SharePoint site
Run:Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive. Sign in with your Microsoft 365 credentials. - Export library items to CSV
Run this script, replacing the library name and output path:$items = Get-PnPListItem -List "Shared Documents" -PageSize 1000 $items | Export-Csv -Path "C:\exports\library_inventory.csv" -NoTypeInformation
The
-PageSize 1000parameter prevents timeouts on large libraries. - Include specific metadata columns
To export custom columns, add the-Fieldsparameter:Get-PnPListItem -List "Shared Documents" -Fields "FileLeafRef","FileSizeDisplay","Editor","ProjectName" | Export-Csv "library.csv" -NoTypeInformation
Replace
ProjectNamewith your actual column internal name.
Common Mistakes When Exporting a Library to CSV
Export button is grayed out or missing
The Export to Excel button disappears if the library exceeds 5,000 items or if your browser blocks pop-ups. Use PowerShell for large libraries. Allow pop-ups for your SharePoint domain in browser settings.
Exported CSV shows only 5,000 rows
SharePoint list view threshold limits exports to 5,000 items. The PowerShell method bypasses this limit. If you must use the ribbon export, create a view with a filter to export smaller batches.
Metadata columns are missing from the CSV
The export only includes columns visible in the current view. Add all needed columns to the view before exporting. For PowerShel, use the -Fields parameter to specify columns by internal name.
CSV contains extra columns like ID or Content Type
The default library view includes many system columns. Create a custom view with only the columns you need, then export that view. In PowerShell, use Select-Object to limit exported properties.
| Export Method | Ribbon Export to Excel | PowerShell PnP.PowerShell |
|---|---|---|
| Maximum items | 5,000 | Unlimited (with pagination) |
| Metadata columns | Only columns in the current view | Any column by internal name |
| Setup time | Less than 1 minute | 10 minutes (install module, write script) |
| Permissions needed | Contribute or higher | Site owner or SharePoint admin |
The ribbon export works best for quick, small inventories. PowerShell is the correct choice for large libraries, custom metadata, or recurring exports. After you export the CSV, you can open it in Excel, import it into Power BI, or use it for migration tools. For monthly automated exports, schedule the PowerShell script using Task Scheduler on a Windows machine.