Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Reading data from excel file getting strange strings.

$
0
0
$xl = New-Object -COM "Excel.Application"
$xl.Visible = $true
$wb = $xl.Workbooks.Open("C:\report030113.xlsx")
$ws = $wb.Sheets.Item(1)
for ($i = 3; $i -le 150) {
  if ($ws.Cells.Item($i, 1).Value2 -ne $null) {
    if($ws.Cells.Item($i, 1).Value2 -notmatch "File" -And $ws.Cells.Item($i, 1).Value2 -notmatch "PDF_Out"){
    $filename = $ws.Cells.Item($i, 1).Value2
        $date = $ws.Cells.Item($i, 2).Value2
            $time = $ws.Cells.Item($i, 3).Value2
     write-host "Filename: "$filename
          write-host "Date: "$date
               write-host "time: "$time
               }
  }
  $i++
}

The filename string is returning exactly how it should but the date and time are not.

Date in the excel file:

2/28/2013

Date I'm getting: 41333

Time in the excel file: 

18:31:08

Time I'm getting: 0.77162037037037

Not sure why it's doing this can anyone help?



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>