문제

I know you can backup site collections with stsadm -o backup, and you can backup sites with stsadm -o export. But what's the best way to copy a list? I've tried to use the save as a list template and include content, but not all the columns came across.

For example I had a lookup to another column in the same list but the data was totally messed up. only about 10% of the values were correct. I heard this is supposed to be available in 2010, but what's the best way to copy a list in 2007.

도움이 되었습니까?

해결책

I used the stsadm extensions to be able to import and export lists and libraries.

다른 팁

You have already tried the best way, Save as Template and add it to the New Site. And to make the Look Up field work refer to this article that provides an alternate to do it.

Also one another way if wanted to do is to Create a List Template and Deploy it as a Feature using WSP solution, but if you are going to use this List only Once then you don't need to create a List Template. One Another item to note in the List Template is you will have to Hand code the XML with the Data contained in the list. Here is a nice article on how to create a List Template.

goign to Site Settings -> Site Content and Structure, I created a new list in the new site with it's default list structure. Then I went to the old list and selected all the data rows then copied them to the new list. SharePoint copied the data and the list structure to the new list and made the new list look and work just like the old list. I was very happy.

Using the content deployment wizard (http://spdeploymentwizard.codeplex.com/ ), you can export a specific List or document library and then import it to another site.

This is a graphical wizard that displays all site content in a tree like view then you can select what lists or libraries to export. You can then use it again to import whatever you exported to the new site.

I am not sure what is the best way, but I did it using a Console App, with following code,

        SPList myDestinationList = web1.Lists[destinationlistName];
        SPList mySourceList = web2.Lists[Form1.OldListName];
        SPQuery mySourceListQuery = new SPQuery();

        mySourceListQuery.Query =

            "<OrderBy><FieldRef Name='a' />" +
                     "<FieldRef Name='b' />" +
            "</OrderBy>";

        SPListItemCollection mySourceItemColl = mySourceList.GetItems(mySourceListQuery);
        foreach (SPListItem mySourceListItem in mySourceItemColl)
        {
            SPListItem myDestinationListItem = myDestinationList.Items.Add();

            if (mySourceListItem["a"] != null)
                myDestinationListItem["a"] = mySourceListItem["Title"];

            if (mySourceListItem["b"] != null)
                myDestinationListItem["b"] = mySourceListItem["Location"];


            web1.AllowUnsafeUpdates = true;
            web2.AllowUnsafeUpdates = true;
            myDestinationListItem.Update();
            web1.AllowUnsafeUpdates = false;
            web1.AllowUnsafeUpdates = false;
        }

It did worked with Custom columns and lookup columns as well.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top