How to read out a date format cell as string from excel with PowerShell?

rated by 0 users
This post has 2 Replies | 2 Followers

Not Ranked
Posts 2
Kokai Posted: 06-22-2009 4:56 AM

Hi all!

May problem is:
I have a scirpt, that read out the data from an excel file:

Quote:
$excel=New-Object -COM Excel.Application
$ci= [System.Globalization.CultureInfo]'en-US'
$src="path:excel.xls"
$book=$excel.Workbooks.PSBase.GetType().InvokeMember('Open', [Reflection.BindingFlags]::InvokeMethod, $null,$excel.Workbooks, $src, $ci)
$sheet= 1
$sh=$book.sheets.item($sheet)

#the read out command:
[string] $sh.Cells.item($row,$col).formulaLocal

But when read out an date format cell, the result not the date, but a number..for example: 2009.06.15 will be: 39979
How can I solve this problem?
Or how can I do, that the srcipt read out the cell as a string?

Thx the help in advance!
Koky

Not Ranked
Posts 1

I would enjoy the answer to this as well.  I understand the numerical value behind the date but cant quite figure out how to change it.

 

-Grahm

Excel Reports

Not Ranked
Posts 1

I found this Excell's formula usefull: TEXT(B3,"mmmm dd")

Where B3 is cell with date and TEXT formula converts it to text the way I want it to be displayed.

 

 

Page 1 of 1 (3 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.