csv - 以以下方式创建 SharePoint 列表到 CSV 报告
解决方案
我们可以使用下面的 PowerShell 来实现它。
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the Web
$web = Get-SPWeb -identity "http://sp2013/sites/team"
#Get the Target List
$list = $web.Lists["TestExportToCSV"]
#Array to Hold Result - PSObjects
$ListItemCollection = @()
#Get All List items
$listItems=$list.Items
foreach($item in $listItems) {
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $item["Title"]
$ExportItem | Add-Member -MemberType NoteProperty -Name "City" -value $item["City1"]
$ExportItem | Add-Member -MemberType NoteProperty -Name "State" -value $item["State1"]
$ExportItem1 = New-Object PSObject
$ExportItem1 | Add-Member -MemberType NoteProperty -name "Title" -value $item["Title"]
$ExportItem1 | Add-Member -MemberType NoteProperty -Name "City" -value $item["City2"]
$ExportItem1 | Add-Member -MemberType NoteProperty -Name "State" -value $item["State2"]
#Add the object with property to an Array
$ListItemCollection += $ExportItem
$ListItemCollection += $ExportItem1
}
#Export the result Array to CSV file
$ListItemCollection | Export-CSV "c:\ListData.csv" -NoTypeInformation
#Dispose the web Object
$web.Dispose()
推荐阅读
- powershell - 使用 Powershell 添加打印机
- javascript - 尝试使用 Onclick 显示表格
- flutter - 定时器不停止
- java - STS 4.12 上缺少导出 WAR
- c# - axios formbody参数为null
- python - 将数据帧值与另一个数据帧值的值进行比较
- html - 在 npm install 之后的每个新项目中,当我运行项目时都会发生此错误
- xml - XSD 或 DTD - 为什么首先使用 DTD?
- javascript - Next.js 中每个路由服务器端的中间件
- ruby-on-rails - 使用 capistrano 部署时 Ruby 解释器或扩展库中的错误