Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SPList.SaveAsTemplate method

Saves the list as a template in the list template gallery and includes the option of saving with or without the data that is contained in the current list.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public void SaveAsTemplate(
	string strFileName,
	string strName,
	string strDescription,
	bool bSaveData


Type: System.String

The file name for the list template with an .stp extension.

Type: System.String

The title for the list template.

Type: System.String

The description for the list template.

Type: System.Boolean

true to save the data of the original list along with the list template; otherwise, false.


Cannot save the list as a template.

The following code example saves a list, including its user data, on a specified site as a template.

This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.

SPSite oSiteCollection = SPContext.Current.Site;
SPList oList = oSiteCollection.AllWebs["Site_Name"].Lists["List_Title"];
oList.SaveAsTemplate("File_Name.stp", "List_Template_Title", 
    "Description", true);

© 2015 Microsoft