OLE Variant

  • Thread starter Brian Helterline
  • Start date
B

Brian Helterline

Hi Ken,

Ken Brown said:
Trying to get excel formatted as dd/mm/yyyy into perl variable

seems to be ruturning ole::variant but i cant get any sense out of return
date

$$item = Variant(VT_DATE, "$sheet->Cells(6,$CurCol)->{Value}");

Syntax Error - there should not be quotes around $sheet.....
$$item = $$item->Date("dd/MM/yyyy");

it keeps returing 30/12/1899 - not overly helpful

any ideas?

A funny coincidence, if you run this:

my $item = Variant(VT_DATE, 0 );
print $item->Date( "dd/MM/yyyy" );

what value to you get? (hint: 30/12/1899)

It seems you don't have a value in Cells(6,$CurCol)

I think you may be over working the problem. The value returned from the
cell
will already be a string that looks like a date. (At least it does on my
system)

One thing to note: if Excel has the date formatted as "dd/mm/yyyy", when I
get
the value of the cell, it looks like "mm/dd/yyyy" which is my default.
E.g. On my system, if the excel cell has the format dd/mm/yyyy and contains
Jan 15, 2003, Excel displays it as 15/01/2003 but if you execute:

print $sheet->Cells(6,$CurCol)->{Value}

I get '1/15/2003'

-brian
 
K

Ken Brown

Trying to get excel formatted as dd/mm/yyyy into perl variable

seems to be ruturning ole::variant but i cant get any sense out of return
date

$$item = Variant(VT_DATE, "$sheet->Cells(6,$CurCol)->{Value}");
$$item = $$item->Date("dd/MM/yyyy");

it keeps returing 30/12/1899 - not overly helpful

any ideas?
 
K

Ken Brown

Checked it out and you were right it does return a date once I sorted things
out

But if the field has a custom date format then it returns a variant

And god only knows how excel is outputting as nothing will format it
correctly

However - simple approach - I just reformat cell before I read it so I know
what I'm reading.

Thanks for the sanity check - simple is best - I just got a bit carried away
for a while

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top