【发布时间】:2018-12-09 12:56:20
【问题描述】:
我正在使用以下代码使用 powershell 读取 excel 文件。 excel 文件中有几个日期列,格式为 yyyy-mm-dd 格式。当 PowerShell 读取日期列时,它会呈现一个数字。如何将此数字更改为真实的日期时间。
$oldci = [System.Threading.Thread]::CurrentThread.CurrentCulture
$newci = [System.Globalization.CultureInfo]"en-US"
$path="C:\project1\Spreadsheet2.xlsx"
$objExcel = New-Object -ComObject "Excel.Application"
$objExcel.visible = $false
[system.threading.Thread]::CurrentThread.CurrentCulture = $newci
$objWorkbook =$objExcel.Workbooks.Open($path)
$worksheet = $objWorkbook.sheets.item("Temp")
Write-Host $worksheet.cells.item(3, 3).value2 //here is a digit.
【问题讨论】:
标签: excel date powershell