Share via

Create views with a .csv file

zennis 20 Reputation points
2024-12-20T08:26:11.8366667+00:00

We have approximately 200+ columns in a list and I need to create 50+ views by column visibility. It will be time consuming if I create them from UI. So can I create views from a .csv file with column structures within its sheets or is there any alternatives easier for us?

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments

Answer accepted by question author

AllenXu-MSFT 24,991 Reputation points Moderator
2024-12-23T02:17:35.0933333+00:00

Hi @zennis,

Firstly, we cannot create views with a .csv file in SharePoint Online. As a workaround, I suggest you create views using the below PnP PowerShell script.

#Config Variables
$SiteURL = "https://xxx.sharepoint.com" 
$ListName= "Projects"
$ViewName= "Active Projects"
$ViewFields = @("ProjectID", "Title","Category","ProjectStatus")
$Query = "<Where><Eq><FieldRef Name = 'ProjectStatus' /><Value Type = 'Choice'>Active</Value></Eq></Where>"
 
#Get Credentials to connect
$Cred = Get-Credential
 
Try {
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Credentials $Cred
 
    #sharepoint online pnp powershell create view
    Add-PnPView -List $ListName -Title $ViewName -ViewType Html -Fields $ViewFields -Query $Query -ErrorAction Stop
    Write-host "View '$ViewName' Created Successfully!" -f Green
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red } 


Additionally, The Add-PnPView cmdlet supports -RowLimit, -SetAsDefault switches. You can also use the Query parameter to set sorting or group by. E.g.,

  • Sort Order: “<OrderBy> <FieldRef Name= ‘Modified’ Ascending=’false’ /> </OrderBy>”
  • Group By: “<GroupBy><FieldRef Name = ‘Status’ /></GroupBy>”

If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.