Create SharePoint list from excel + programmatically

In this SharePoint tutorial, we will discuss how to create a list from excel in SharePoint Online and we will check the below things:

  • Create a list from excel in SharePoint Online
  • Create list from existing list in SharePoint Online
  • SharePoint create list from template
  • Create SharePoint Online List Programmatically using PnP CSOM
  • Create SharePoint Online List Programmatically using PnP
  • Create a column in SharePoint Online list using PnP
  • Create Choice Field in SharePoint Online List using PnP CSOM
  • Create Multi Choice Field in SharePoint Online List using PnP
  • Create a SharePoint list using PnP

This is a requirement that comes from most of the business users or site owners, can we create a list in SharePoint Online from an excel?

Previously, we can use the import spreadsheet option to create a list from an excel. But your browser requires ActiveX control. Apart from this, the import spreadsheet is not a user-friendly way to create the list.

This will work in SharePoint Online modern site.

Create a list from excel in SharePoint Online

You can follow the below steps to create a list from excel in SharePoint Online.

Step-1: Format Excel as Table

The first thing we need to do is to format the excel as table.

Here, I have created an excel with the below columns:

  • Employee Name
  • Address
  • Experience
  • Salary

And the excel looks like below:

create a sharepoint list from excel
Create a list from excel in SharePoint

Once the excel is ready, Open the excel, select the records and click on “Format as table” like below:

create a sharepoint online list from excel
Create a list from excel in SharePoint online

Then it will open the Format As Table dialog box, here check the checkbox “My table has headers“.

SharePoint Online create a list from excel
create sharepoint list from excel

Now, your excel table should looks like below:

SharePoint create a list from excel
create sharepoint list from excel without import spreadsheet

Step-2: Upload excel to SharePoint Online Documents document library (Optional

Now, you can upload the excel file to the SharePoint documents (Shared Documents) document library.

But this is an optional step, you can directly also upload the excel while creating the list from the SharePoint Online site.

You can simply, drag the file to the shared documents document library in SharePoint.

Step-3 Create List from Site Contents Page

Now, we will create a list from the site contents page from the SharePoint Online site.

Open the SharePoint Site, Go to the Site Contents page. Then select +New -> List.

create sharepoint list from excel file
create sharepoint list from excel file

Here, there are 3 ways you can create list:

Here Select From Excel.

How to create a list in SharePoint Online site
create sharepoint list
  • Then provide a List name in the Create a list field.
  • Then either you can upload the excel file directly from your desktop.
  • Or you can select the excel from the SharePoint Online document library.

Here I have uploaded the excel file directly from my desktop.

Then it will load all the data from the excel file with the column names and the data type for each column.

Here you can change the data type from the drop-down for each column like below (last column).

If the excel file contains multiple tables, then you can select the table from the Select a table from this file dropdown list.

create sharepoint online list from excel
create sharepoint online list from excel

Then click on the Create button to create the list.

Now, you can see the list got created like below that will be having the same list name, columns and column data types.

create list from excel sharepoint
create list from excel in SharePoint online

This is how we can create list from excel in SharePoint online.

What will happen if you do not format excel as table

In the previous section we discussed, we need to format as a table the excel data. But what will happen if we do not do that?

Once you upload the excel file, then it will ask you to do the below 4 steps:

  1. Click on the Open button, that will open the excel file using excel online.
  2. Then Select the columns and data that you want to include.
  3. Then click on Format as Table.
  4. Click on Refresh once you back to this page.
create list from excel in sharepoint online
create list from excel in sharepoint online

All other steps will be same as explained about.

Can I create this in the SharePoint Online classic site?

As of now you can not create a list in SharePoint Online classic site from a list. This will work in the modern SharePoint experience.

Basically, this option is available in the modern site contents page in SharePoint Online.

Create list from existing list in SharePoint Online

Now, let us see, how to create a list from an existing list in SharePoint Online. In classic SharePoint sites, we use the Save list as template option.

In the SharePoint Online modern sites, there is no Save list as template option.

This will be helpful when you try to replicate a SharePoint Online list from another list.

Open the SharePoint Online site and go to the Site Contents page. Make sure to use the modern site contents page.

Then click on New -> List like below:

create a list from an existing list sharepoint
Create list from existing list in SharePoint Online

Then you have the option to either create a new list or you can choose From an existing list.

Give a name for the list.

In the Select a site, it will populate all the site the user having access to from there select the site from where your existing list is presented.

Once you will select the site, it will display all the lists from the SharePoint site.

create list from existing list in sharepoint online
Create list from existing list in SharePoint Online

Then it will create the list like below, which will have all the columns from the existing SharePoint list.

how to create a list from an existing list sharepoint
Create list from existing list in SharePoint Online

This is how we can create list from existing list in SharePoint Online.

Few Points to Remember

But you have to remember few points.

  • The site contents page from where you will create a list, should be a modern site contents page.
  • When you will create the new list, it will create the entire structure of the list, like forms, formatting, and custom metadata columns that will be copied also.
  • But the SharePoint list contents will not be copied.
  • Discussion board and document libraries are not supported to create a list from an existing list.

In the future, Microsoft will release another new feature to Create a list From Excel in SharePoint Online very soon.

You may like Microsoft Lists – Create a List from Excel.

Here we learned, how to create a list in SharePoint Online.

SharePoint create list from template

In this SharePoint tutorial, let us see how to create a SharePoint list from a template. We can create a SharePoint list using a custom list template in SharePoint Online using CSOM (.Net managed object model code). Learn here how to create a list from list template in SharePoint Online 2013 programmatically.

Here we have customized a list in SharePoint online site and we saved the list as a template. Now our requirement is to create a list using a custom list template programmatically SharePoint using CSOM (Client site object model).

Once you create a list from the list template, the list structure will be the same as the list template and also if any data will be there in the template, the data will also appear.

Here first we need to retrieve all the custom list templates using GetCustomListTemplates method in csom. In this case my custom list template name is “WorkflowMailTemplates”.

And we are retrieveing the particular list template by comparing the list template name like below:

ListTemplate listTemplate = templates.First(listTemp => listTemp.Name == "MyCustomListTemplate");

SharePoint create list from template

Let us check how to create list from template in SharePoint. Below is the full code to create list from list template in SharePoint Online 2013 programmatically.

public void CreateTemporaryList(string URL)
{
using (ClientContext clientContext = new ClientContext(URL))
{
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new SharePointOnlineCredentials(GetSPOAccountName(), GetSPOSecureStringPassword());
ListTemplateCollection templates = clientContext.Site.GetCustomListTemplates(clientContext.Web);
clientContext.Load(templates);
clientContext.ExecuteQuery();
var listCreationInfo = new ListCreationInformation
{
Title = "MyTempList",
Description = "This is our temporary list created from list template"
};
ListTemplate listTemplate = templates.First(listTemp => listTemp.Name == "MyCustomListTemplate");
listCreationInfo.ListTemplate = listTemplate;
listCreationInfo.TemplateFeatureId = listTemplate.FeatureId;
listCreationInfo.TemplateType = listTemplate.ListTemplateTypeKind;
clientContext.Web.Lists.Add(listCreationInfo);
clientContext.ExecuteQuery();
}
}
private static SecureString GetSPOSecureStringPassword()
{
try
{
var secureString = new SecureString();
foreach (char c in ConfigurationManager.AppSettings["SPOPassword"])
{
secureString.AppendChar(c);
}
return secureString;
}
catch
{
throw;
}
}
private static string GetSPOAccountName()
{
try
{
return ConfigurationManager.AppSettings["SPOAccount"];
}
catch
{
throw;
}
}

This is how to create SharePoint list from template.

ListCreationInformation does not contain a definition for ListTemplate and no extension method ListTemplate accepting a first argument of type ListCreationInformation could be found

We will discuss how we can resolve the below issue which comes when we were trying to create a sharepoint list from a custom list template using c#.net .net managed object model code.

But we got the below error in the below line:

listCreationInfo.ListTemplate = listTemplate;

The error comes as:

‘ListCreationInformation’ does not contain a definition for ‘ListTemplate’ and no extension method ‘ListTemplate’ accepting a first argument of type ‘ListCreationInformation’ could be found (are you missing a using directive or an assembly reference?)

The solution is to use the updated dll (Microsoft.SharePoint.Client.dll).

Here I have used the 16.1.6420.1200 version of Microsoft.SharePoint.Client.dll.

Once you will execute the above code, it will create the list by using the custom list template in SharePoint online site. Now, you can create SharePoint list from template. I hope you get to know now how to create sharepoint list from template and we know the csom code to create a sharepoint list from a template and sharepoint online create list from template.

Create SharePoint Online List Programmatically using PnP CSOM

In this PnP SharePoint tutorial, we will discuss how to Create SharePoint Online List Programmatically using PnP CSOM, and then we will see how to create or add columns/fields in SharePoint Online list using PnP.

We will also check how to create a choice column in the SharePoint Online list using PnP CSOM and how to add a multi-choice field in the SharePoint Online list using PnP CSOM library.

If you are new to PnP, follow this article on PnP SharePoint Online Development using Patterns and Practices (PnP)

Create SharePoint Online List Programmatically using PnP

The below references we have to use in the code to work with PnP libraries:

  • Microsoft.SharePoint.Client
  • OfficeDevPnP.Core

Here also I have created an asp.net application and added a button. Just click on the button, the list will be created with fields in SharePoint Online using the PnP core CSOM library.

<asp:Button ID="btnCreateListWithFields" runat="server" Text="Create List With Fields" OnClick="btnCreateListWithFields_Click" />
    <asp:Label ID="lblCreateListWithFields" runat="server" Text=""></asp:Label>

Below given snippet code creates a SharePoint Online list and fields in SharePoint online using PnP.

protected void btnCreateListWithFields_Click(object sender, EventArgs e)
        {
            CreateListWithFields();
        }
void CreateListWithFields()
 {
 try
 {
using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteURL, userName, password))
{                                  
if (ctx.Web.ListExists("Employees"))
ctx.Web.GetListByTitle("Employees").DeleteObject();
ctx.ExecuteQueryRetry();
List employeesList = ListExtensions.CreateList(ctx.Web, ListTemplateType.GenericList, "Employees", false, false);
FieldCreationInformation fldEmpID = new FieldCreationInformation(FieldType.Number);
fldEmpID.DisplayName = "Employee ID";
fldEmpID.InternalName = "EmpID";
fldEmpID.AddToDefaultView = true;
fldEmpID.Id = Guid.NewGuid();
employeesList.CreateField(fldEmpID);
FieldCreationInformation fldEmpName = new FieldCreationInformation(FieldType.Text);
fldEmpName.DisplayName = "Employee Name";
fldEmpName.InternalName = "EmpName";
fldEmpName.AddToDefaultView = true;
fldEmpName.Id = Guid.NewGuid();
employeesList.CreateField(fldEmpName);
employeesList.Update();
ctx.ExecuteQueryRetry();
lblCreateListWithFields.Text = "Custom List with Fields Created Successfully";
 }
 }
catch (Exception ex)
 {
 }
 }

Run our application and click on the button “Create List With Fields” on the page.

create list programmatically in SharePoint
create list programmatically in SharePoint

Now our new SharePoint List “Employees” with few fields are created in the list.

create list programmatically in SharePoint using PnP core csom library
create list programmatically in SharePoint using PnP core csom library

In this SharePoint PnP article, we learned about how to create a list and add fields or columns using SharePoint PnP core CSOM Library.

Create a column in SharePoint Online list using PnP

Now, we will see how to create a field or column in the SharePoint Online list using the PnP core CSOM Library. We also know how to show/hide the fields in the NewForm or EditForm or DisplayForm of the sharepoint List using PnP.

Following functions are used for creating field in SharePoint List.

  • FieldExistsByName() is used to check the field exist in the SharePoint list or not.
  • SetShowInNewForm(), SetShowInEditForm() and SetShowInDisplayForm() functions are used to show or hide the field in the SharePoint list.

Here also I have created an asp.net application and added a button. Just click on the button, Field will create in the SharePoint Online List using the PnP core CSOM library.

<div>
<asp:Button ID="btnCreatefieldInCustomList" runat="server" Text="Create Field in Custom List" OnClick="btnCreatefieldInCustomList_Click" /><br />
<asp:Label ID="lblCreatefield" runat="server" Text=""></asp:Label>
</div>

Follow the below code for creating a field/column in the SharePoint List using PnP.

AuthenticationManager authMgr = new AuthenticationManager();
string siteURL = "https://onlysharepoint2013.sharepoint.com/sites/TSInfoPNP";
string userName = "********@DOMAINAME.onmicrosoft.com";
string password = "*******";
protected void btnCreatefieldInCustomList_Click(object sender, EventArgs e)
{
    CreateFieldinTheList();
}
void CreateFieldinTheList()
{
string listName ="Order Details";
try
{
using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteURL, userName, password))
{
ctx.Load(ctx.Web);
ctx.ExecuteQueryRetry();
string displayName = "Order Number";
string internalName = "OrderNumber";	
FieldType fieldType = FieldType.Number;														
List olist = ctx.Web.GetListByTitle(listName);
bool listExists = ctx.Site.RootWeb.ListExists(listName);
if (listExists)
{
bool fieldexists = olist.FieldExistsByName(internalName);
if (!fieldexists)
{
FieldCreationInformation newFieldInfo = new FieldCreationInformation(fieldType);
newFieldInfo.DisplayName = displayName;
newFieldInfo.InternalName = internalName;
newFieldInfo.Id = Guid.NewGuid();
newFieldInfo.AddToDefaultView = true;	
			
Field ofield = olist.CreateField(newFieldInfo);
ofield.Description = "Product Order Number";
ofield.Required = true;						ofield.SetShowInNewForm(true);							ofield.SetShowInEditForm(false);							ofield.SetShowInDisplayForm(true);
ofield.Update();							ctx.ExecuteQueryRetry();
lblCreatefield.Text = "Field Created Successfully in the List";
}
else
{
lblCreatefield.Text = "Field is Already Exist in the List";
}
}
else
{
lblCreatefield.Text = "List Does not exists";
}										
}
}
catch (Exception ex) {
lblCreatefield.Text = ex.StackTrace;
//lblCreatefield.Text = "Problem in creating field in the list";
}
}

Run your application and click on button “Create Field in Custom List”.

SharePoint create field in the SharePoint list pro grammatically using PnP Core CSOM
SharePoint create field programmatically using PnP Core CSOM

Go to our SharePoint Online List and Now see the field is added in our SharePoint Online list.

Create Custom Field/Column in SharePoint Online List using PnP
Create Custom Field/Column in SharePoint Online List using PnP

Go to List Setting -> Click on Column/Field “Order Number” which we created now. In Edit Column, we can see the column/Field details.

Create Custom Field/Column in SharePoint Online List using PnP
Create Custom Field/Column in SharePoint Online List using PnP

Check the field/column is shown in the Edit Form it is hidden because we are setting the field/column in the code as “ofield.SetShowInEditForm(false);”.

Note: The field/column “Order Number” shown in the “QuickEdit” view Form only not like as in the EditForm in SharePoint list.

sharepoint online create field programmatically using PnP Core csom library
sharepoint online create field programmatically using PnP Core csom library

The same way you can check on NewForm and DisplayForm in SharePoint Online List.

Create Choice Field in SharePoint Online List using PnP CSOM

Now, let us see how to create a choice field in SharePoint online list using PnP CSOM.

The name of the choice column will be Status and it will have options like New, Pending, and Delivered in the SharePoint List name called “Order Details”.

The below references we have to use in the code to work with PnP libraries:

  • Microsoft.SharePoint.Client
  • OfficeDevPnP.Core
  • OfficeDevPnP.Core.Entities

Following classes are used for creating Choice field/column in SharePoint Library.

  • FieldCreationInformation.
  • Field
  • FieldChoice

Following functions are used for creating Choice field/column in SharePoint Library.

  • CreateField() function used to create field in the SharePoint list.

Here I have created an asp.net application and I have added a button. Just click on the button, Choice Field(dropdown) will be created in SharePoint Online List using the PnP core CSOM library.

<div>
<asp:Button ID="btnCreateChoiceField" runat="server" Text="Create Choice Field In Custom List" OnClick="btnCreateChoiceField_Click" /><br />
<asp:Label ID="lblCreateChoiceField" runat="server" Text=""></asp:Label>
</div>

Below given snippet code create a choice field (dropdown) in SharePoint Online List using PnP.

AuthenticationManager authMgr = new AuthenticationManager();
string siteURL = https://DomainName.sharepoint.com/sites/TSInfoPNP";
string userName = "*******@DomainName.onmicrosoft.com";
string password = "******";
protected void btnCreateChoiceField_Click(object sender, EventArgs e)
{
	Createchoicefield();
}
void Createchoicefield()
{

string listName = "Order Details";
try
{
using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteURL, userName, password))
{
ctx.Load(ctx.Web);
ctx.ExecuteQueryRetry();
List oList = ctx.Site.RootWeb.GetListByTitle(listName);
FieldCreationInformation choiceField = new FieldCreationInformation(FieldType.Choice);
choiceField.DisplayName = "Status";
choiceField.InternalName = "ProductOrderStatus";
choiceField.Id = Guid.NewGuid();
choiceField.AddToDefaultView = true;
choiceField.Required = true;
Field oField = oList.CreateField(choiceField);
FieldChoice fc = ctx.CastTo<FieldChoice>(oField);
List<string> options = new List<string>(fc.Choices);
options.Add("New");
options.Add("Pending");
options.Add("Delivered");
fc.Choices = options.ToArray();
// Update the choice field  
fc.Update();
ctx.ExecuteQueryRetry();
lblCreateChoiceField.Text = "Choice Field Created SuccesFully";
}
}
catch (Exception ex)
{
lblCreateChoiceField.Text = "Problem in createing Choice Field in the list";
}
}

Run the application and click on the button “Create Choice Field In Custom List” on the page.

create choice field in sharepoint list programmatically
create choice field in sharepoint list programmatically

Now the choice field (dropdown) is created in our SharePoint Online list. Go to the SharePoint list settings and scroll the page down to columns.

SharePoint create choice field programmatically using PnP core csom library
SharePoint create choice field programmatically using PnP core csom library

Click on Status” column and see the settings below created for the “Status” column.

create choice field in sharepoint list programmatically uisng pnp core csom library
create choice field in sharepoint list programmatically uisng pnp core csom library

Create Multi Choice Field in SharePoint Online List using PnP

Now we will see, how to create Multi choice Field in the SharePoint Online list using the PnP CSOM Library. A MultiChoice field or column allows users to select multiple options in the SharePoint List.

In this example, we will create a MultiChoice field/Column name “Technology” with options are like DotNet, SharePoint on-premises, and SharePoint Online in the SharePoint List name called “Employees”.

The following classes are used for creating the Choice field/column in the SharePoint Library.

  • FieldCreationInformation.
  • Field
  • FieldMultiChoice

Following functions are used for creating Choice field/column in SharePoint Library.

  • CreateField() function used to create field in the SharePoint list.

You can use the same asp.net application or you can add a new asp.net application. Just click on the button, MultiChoice Field(dropdown) is created in SharePoint Online List using the PnP core CSOM library.

<div>
<asp:Button ID="btnCreateMultiChoiceField" runat="server" Text="Create Multi Choice Field In The SharePoint List" OnClick="btnCreateMultiChoiceField_Click" />
<asp:Label ID="lblCreateMultiChoiceField" runat="server" Text=""></asp:Label>
</div>

Below given snippet code create a MultiChoice field(CheckBoxes) in SharePoint Online List using PnP.

AuthenticationManager authMgr = new AuthenticationManager();
string siteURL = https://DomainName.sharepoint.com/sites/TSInfoPNP";
string userName = "*******@DomainName.onmicrosoft.com";
string password = "******";
protected void btnCreateMultiChoiceField_Click(object sender, EventArgs e)
{
			CreateMultiChoicefield();
}

void CreateMultiChoicefield()
{
string listName = "Employees";
try
{
using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteURL, userName, password))
{
ctx.Load(ctx.Web);
ctx.ExecuteQueryRetry();
FieldCreationInformation choiceField = new FieldCreationInformation(FieldType.MultiChoice);
choiceField.DisplayName = "Technology";
choiceField.InternalName = "Technology";
choiceField.Id = Guid.NewGuid();
choiceField.AddToDefaultView = true;
choiceField.Required = true;
List oList = ctx.Site.RootWeb.GetListByTitle(listName);
Field oField = oList.CreateField(choiceField);
FieldMultiChoice fmc = ctx.CastTo<FieldMultiChoice>(oField);
List<string> options = new List<string>(fmc.Choices);
options.Add("DotNet");
options.Add("SharePoint OnPremises");
options.Add("Sharepoint Online");
fmc.Choices = options.ToArray();
// Update the choice field  
fmc.Update();
ctx.ExecuteQueryRetry();
lblCreateMultiChoiceField.Text = "Multi Choice Field Created SuccesFully";
}
}
catch (Exception ex)
{
lblCreateMultiChoiceField.Text = "Problem in createing Multi Choice Field in the list";
}
}

Run our application and click on the button “Create MultiChoice Field In SharePoint List” on the page.

sharepoint create multi choice field programmatically
sharepoint create multi choice field programmatically

Now the Multichoice field(CheckBoxes) is created in our SharePoint Online list. Go to our list ->list settings. Scroll down the page there click on new column name “Technology”.

sharepoint create multi choice field programmatically using PnP Core CSOM Library
sharepoint create multi choice field programmatically using PnP Core CSOM Library

See the Multi Choice Field (check boxes) is appeared in the SharePoint list.

sharepoint create multi choice field programmatically using PnP
sharepoint create multi choice field programmatically using PnP

Follow the below links create list in sharepoint Online/2019/2016/2013:

I hope this PnP SharePoint tutorial explains, how to create a SharePoint list using PnP and how to create or add columns to the SharePoint Online list using PnP. We also learned:

  • Create SharePoint Online List Programmatically using PnP
  • Create a column in SharePoint Online list using PnP
  • Create Choice Field in SharePoint Online List using PnP CSOM
  • Create Multi Choice Field in SharePoint Online List using PnP

Create a SharePoint list using PnP

This PnP SharePoint tutorial explains, how to create a SharePoint list using PnP CSOM programmatically. We will also see how to enable few properties while creating the SharePoint list like EnableVersioning, OnQuickLaunch, etc.

The PnP code will also check if the list does not exist then it will create the list. If the SharePoint list exists, then it will not try to create the list.

Create a SharePoint list using PnP

The below references we have to use in the code to work with PnP libraries.

  • Microsoft.SharePoint.Client
  • OfficeDevPnP.Core

The following functions are used for creating a List in SharePoint Online using PnP SharePoint.

  • ListExists() is used to check the list is existing or not in SharePoint Online Site.
  • CreateList() is used to create a list in the SharePoint Online Site.

See the below function how it is working when creating a custom list in Sharepoint online site. You can find this line of code in the below example.

CreateList(ListTemplateType.GenericList,listName,true,true,"",true,false);
  • ListTemplateType.GenericList: it will create a generic list in our SharePoint Online Site.
  • listName: it is the name of our Sharepoint custom list.
  • First “true”: Enabled versioning in the SharePoint custom list(optional).
  • Second “true”: update and ExecuteQuery is set to true here(optional).
  • Third “true”: It is Enabled the Content-type for our Sharepoint Custom List.

Follow the below code it will create a custom list in your SharePoint Online Site.

AuthenticationManager authMgr = new AuthenticationManager();
string siteURL = "https://onlysharepoint2013.sharepoint.com/sites/TSInfoPNP";
string userName = "********@DomainName.onmicrosoft.com";
string password = "*******";
protected void btnCreateCutomList_Click(object sender, EventArgs e)
{
	createList();
}

void createList()
{
string listName = "Order Details";		
try
{
using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteURL, userName, password))
{
ctx.Load(ctx.Web);
ctx.ExecuteQueryRetry();
bool listExists = ctx.Site.RootWeb.ListExists(listName);
if (!listExists)
{
							
List olist = ctx.Web.CreateList(ListTemplateType.GenericList,listName,true,true,"",true,false);
olist.Description = "List has Product order details";
olist.OnQuickLaunch = true;
//olist.EnableVersioning = true;
olist.Update();
ctx.Load(olist);
ctx.ExecuteQueryRetry();
lblCreateCustomList.Text = "List Created Successfully";
}
else
{
lblCreateCustomList.Text = "List already exists";
}
}	
}
catch (Exception ex)
{
lblCreateCustomList.Text = ex.StackTrace;
}
}

Run your application and click on button “Create Custom List”.

create sharepoint list using pnp
create sharepoint list using pnp

Now your sharepoint custom list created successfully in your site. Go to “Site Contents” in your SharePoint Online site.

create SharePoint list programmatically using PnP Core CSOM Library
create SharePoint list programmatically using PnP Core CSOM Library

Go to your SharePoint List Settings -> click on “List name, description, and navigation”.

In general settings Name, Description added and Navigation is enabled “Yes” for the Newly created SharePoint custom list.

create list programmatically in SharePoint PnP
create list programmatically in SharePoint

Go to List Settings-> click on “Versioning Settings”. Check versioning settings are enabled for newly created the SharePoint Custom List.

create SharePoint list programmatically using PnP Core CSOM Library
create SharePoint list programmatically using PnP Core CSOM Library

Go to List Settings -> click on “Advanced Settings”. Check the “Allow the management of Content-type” is enabled for Newly created the SharePoint Custom List.

create SharePoint list programmatically using PnP Core CSOM Library
create SharePoint list programmatically using PnP Core CSOM Library

This is how to check a list is existing or not in the SharePoint site. We also saw how to create a SharePoint list using PnP Core CSOM Library.

In this SharePoint tutorial, we learned how to create list from excel in SharePoint online and learn the below things:

  • Create a list from excel in SharePoint Online
  • Create list from existing list in SharePoint Online
  • SharePoint create list from template
  • Create SharePoint Online List Programmatically using PnP CSOM
  • Create SharePoint Online List Programmatically using PnP
  • Create a column in SharePoint Online list using PnP
  • Create Choice Field in SharePoint Online List using PnP CSOM
  • Create Multi Choice Field in SharePoint Online List using PnP
  • Create a SharePoint list using PnP
>