导出导入的CSV时,它包括标题,但不包括标题下的信息
我有从路径导入CSV的代码,然后我希望代码将CSV变成Excel,而Excel仅包含某些标头。我在Excel中发现,它将具有标题,但没有标题下的信息。有人可以解释我做错了什么吗?
$csv = Import-Csv -Path $path
$csv | Export-Csv -Path "Y:\Client Case Files\$company\$incidentfolder\signinlogs.csv" -NoTypeInformation
# sort and filter information for xlsx
$excel = $csv | Select-Object createdDateTime,UserDisplayName,UserPrincipleName,IpAddress,AppDisplayName,ClientAppUsed,IsInteractive,RiskDetail,RiskLevelAggregated,RiskState
$excel | Export-Excel -Path "Y:\Client Case Files\$company\$incidentfolder\signinlogs.xlsx"
I have code to import a csv from a path, then I want the code to turn the csv into an excel, with the excel only containing certain headers. I found though in the excel, it will have the headers but none of the information under the headers. Can someone explain what I'm doing wrong?
$csv = Import-Csv -Path $path
$csv | Export-Csv -Path "Y:\Client Case Files\$company\$incidentfolder\signinlogs.csv" -NoTypeInformation
# sort and filter information for xlsx
$excel = $csv | Select-Object createdDateTime,UserDisplayName,UserPrincipleName,IpAddress,AppDisplayName,ClientAppUsed,IsInteractive,RiskDetail,RiskLevelAggregated,RiskState
$excel | Export-Excel -Path "Y:\Client Case Files\$company\$incidentfolder\signinlogs.xlsx"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查是$ excel变量是否需要数据?
如果不是您的CSV文件DAT标头,则在结束或开始时具有额外的空间。
尝试下面的测试,
如果也不提供数据可能会与您的Excel模块发行
Check is $excel variable have the data required ?
if not probably your csv file dat headers have extra space at end or start.
try testing below
If that also not giving the data probably issue with your excel module