首页 > 代码库 > share point 读取 List数据

share point 读取 List数据

SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite oSite = new SPSite(siteUrl))
                {
                    foreach (SPWeb oWeb in oSite.AllWebs)
                    {
                        foreach (SPList oList in oWeb.Lists)
                        {
                            if (oList.Title != "Organizations")
                                continue;

                            var sb = new StringBuilder();
                            sb.AppendLine(oList.Title);
                            foreach (SPListItem oItem in oList.Items)
                            {
                                if (oItem.Versions.Cast<SPListItemVersion>().FirstOrDefault(v => v.Level == SPFileLevel.Published) != null)
                                {
                                    foreach (SPField fd in oItem.Fields)
                                    {
                                        object value =http://www.mamicode.com/ oItem[fd.Id];
                                        sb.AppendFormat("[{0}]={1}\t;", fd.Title ,value ?? string.Empty);
                                    }
                                }
                                sb.AppendLine();
                            }
                            
                            Debug.Print(sb.ToString());
                            return;
                        }
                    }
                }
            });