web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : Oy2aRYNZDli535yMGGawRa
Power Apps - Building Power Apps
Answered

PS Command for import from Excel to SharePoint

Like (0) ShareShare
ReportReport
Posted on 1 Aug 2019 12:03:28 by 14

Hello everybody,

I have a list in SharePoint with 10 columns and I always get excel files sent with the exact same 10 columns. Now I would like to transfer the Excel content to the SharePoint list. Is there a Powershell command that makes an import possible?

P.S. There is an export button at excel, but he keeps putting me on a new list in SharePoint. I would like to use the same list.

Best regards Christian

Categories:
  • Christian866 Profile Picture
    14 on 06 Aug 2019 at 11:23:39
    Re: PS Command for import from Excel to SharePoint
    I have the solution. There was a delimiter missing. The CSV had to be separated per column entry.
    Here is the code:

     

    $CustomerData = Import-CSV “D:\Test.csv” -Delimiter ";"

     

    PS C:\WINDOWS\system32> foreach ($Record in $CustomerData){
    Add-PnPListItem -List "TestCSV2" -Values @{
    "Title"= $Record.'Personalnummer';
    "Personalnummer"= $Record.'Personalnummer';
    "Vorname"= $Record.'Vorname'
    }
    }

  • Christian866 Profile Picture
    14 on 06 Aug 2019 at 07:26:02
    Re: PS Command for import from Excel to SharePoint

    Hi v-xida-msft,

     

    Thank you for your answer.
    
    If I add the "title" comes following (see picture). When I name the title as german name "Titel", he says he does not know the column.

    Bild1.PNGBild2.PNGBild2.PNG
  • Verified answer
    v-xida-msft Profile Picture
    on 06 Aug 2019 at 01:33:44
    Re: PS Command for import from Excel to SharePoint

    Hi @Christian866 ,

    Have you specified the Title column within the Foreach function in your PowerShell window?

     

    Please consider modify your Foreach function as below:

    foreach ($Record in $CustomerData){
    Add-PnPListItem -List "TestCSV" -Values @{
     "Title"= $Record.'Personalnummer';
     "Personalnummer"= $Record.'Personalnummer';
     "Vorname"= $Record.'Vorname'
    }
    }

    please consider take a try with above PowerShell cmdlet, then check if the issue is solved.

     

    Best regards,

  • Christian866 Profile Picture
    14 on 05 Aug 2019 at 09:36:38
    Re: PS Command for import from Excel to SharePoint
    Here is the new list ... unfortunately empty again with the same foreach loop.
    You can now see the contents of the csv file as well.
    Bild1.PNGBild2.PNG
     
  • v-xida-msft Profile Picture
    on 05 Aug 2019 at 09:23:18
    Re: PS Command for import from Excel to SharePoint

    Hi @Christian866 ,

    Yeah, you are right.

     

    Please take a try with your new created SP List, try the Foreach function in your PowerShell window again, check if the issue is fixed.

     

    Best regards,

  • Christian866 Profile Picture
    14 on 05 Aug 2019 at 09:12:53
    Re: PS Command for import from Excel to SharePoint
    I have now deleted the list and created one again with the same name.
    The title I left, only the first name and staff number I have created. Is this correct?

    CSVlist.PNG

    Maybe you wanna see my csv file?
  • v-xida-msft Profile Picture
    on 05 Aug 2019 at 08:47:55
    Re: PS Command for import from Excel to SharePoint

    Hi @Christian866 ,

    Do you rename the Title column into "Personalnummber" column in your TestCSV SP List?

     

    Please do not rename the Title column within your TestCSV SP List when you import CSV Data from your CSV file into your SP list using PowerShell cmdlet.

     

    On your side, please consider change your "Personalnummber" column back to Title column in your TestCSV SP List, or re-create a new SP List, then try the Foreach function again, check if the issue is solved.

     

    Best regards,

  • Christian866 Profile Picture
    14 on 05 Aug 2019 at 08:31:13
    Re: PS Command for import from Excel to SharePoint
    I have now managed to import the data, but only empty lines in the Sharepoint list (see the gray lines in the picture). How can something like that happen?

    PS.PNGemptylines.PNG
     
  • v-xida-msft Profile Picture
    on 05 Aug 2019 at 05:06:59
    Re: PS Command for import from Excel to SharePoint

    Hi @Christian866 ,

    When you execute the Foreach action within your PowerShell window, you need to specify the List Name you want to import your CSV data to using following cmdlet:

    Add-PnPListItem -List "Customer Database" -Values @{...}

     5.JPG

     

    In addition, for your second question, the answer is YES. You could have multiple lists on your SP Site.

     

    Best regards,

  • Christian866 Profile Picture
    14 on 02 Aug 2019 at 11:30:11
    Re: PS Command for import from Excel to SharePoint
    Hello thank you for the quick feedback.
    
    I'm just trying to go through the tutorial (https://practical365.com/sharepoint-online/csv-file-to-sharepoint/).
    The First steps was fine.

    i Connect to the SharePoint site and i import my csv to view all rows in Powershell. it works

    I do not understand how he knows which list he should take on the URL? I can have multiple lists on the SharePoint site?
    Best regards Christian

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473