question

VeeruDasa-3093 avatar image
0 Votes"
VeeruDasa-3093 asked AllenXu-MSFT commented

get List items from SharePoint Online to SharePoint on-premise

Hi,

I am having SharePoint online Site with a list containing List Fields, basically want to keep my data in Online.

I need to get all the list items into my SharePoint 2013 On premises farm Site and display on the publishing page or site pages.

help me to solve this issue.

Thanks.

office-sharepoint-onlinesharepoint-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AllenXu-MSFT avatar image
0 Votes"
AllenXu-MSFT answered AllenXu-MSFT commented

Hi @VeeruDasa-3093 ,

To get all the list items from SharePoint Online and display them on SharePoint On-premise pages, please take a reference to the below steps.

1.Access the source list in SharePoint Online and Select Export > Export to CSV file in the ribbon.
124131-image.png
2.Use the below PowerShell script to import from CSV file to a list in SharePoint-Onpremise.

  Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
     
 #Read the CSV file
 $CSVData = Import-CSV -path "C:\Data.csv"
    
 #Get the Web
 $web = Get-SPWeb -identity "http://sp/"
     
 #Get the Target List
 $list = $web.Lists["test01"]
        
 #Iterate through each Row in the CSV
 foreach ($row in $CSVData)
  {
    $item = $list.Items.Add();
        
    $item["Title"] = $row.Title
    $item["Test"] = $row.Test
    $item["Description"] = $row.Description
    
    $item.Update()
  }

Note: In my case, my source list in the .csv file is shown in the below screenshot and the .csv file is stored in C:\Data.csv. My target list in SharePoint On-premise is named "test01". You have to create the target list and create the same columns(names and column types) as the source list in the target list before executing the script.
124133-image.png
You need to modify above script based on the values of your own list/columns/site. If you have People fileds or Date fileds, you have use svript like below in foreach ($row in $CSVData) to import those fields to the list.

  #Set the People Picker Field value
  $item["People"] = Get-SPUser -Identity $row.People -web "http://sp/"
         
  #Set the Date Field value
  $item["Date"] = Get-Date $row.Date

3.After importing from .CSV file to the SharePoint On-premise list, You can access the page > edit the page > INSERT Web Part > Select the list from the Apps > Add.
124049-image.png


If an Answer is helpful, please click "Accept Answer" and upvote it.
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.


image.png (9.6 KiB)
image.png (5.7 KiB)
image.png (65.4 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@VeeruDasa-3093,

Is there any update on this thread? I'm looking froward to your reply.

0 Votes 0 ·