Ask a Question related to Perl / CGI, Design and Development.

  1. #1

    Default Re: OLE Variant

    Hi Ken,

    "Ken Brown" <ken.brown@dialwrap.co.uk> wrote in message
    news:bdshcf$t60$1@news6.svr.pol.co.uk...
    > 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


    Brian Helterline Guest

  2. Similar Questions and Discussions

    1. SELECT * variant idea, is there something like this...
      Hi Often I find myself working in a query where I need to select one or two fields from source table A as renamed objects ( usually to prevent...
    2. variant as in parameter
      Consider the following: there's a COM component that expects one parameter, the type can be either a BSTR or IDispatch *. I wanted to use a...
    3. passing C++ object in VARIANT
      I hope I unerstand the question correctly but normally its done like this. IDispatch* pDisp VariantInit(rVal); if (SUCCEEDED(hr =...
    4. UDF Parameters always Variant - help!!
      If I make a dataadapter containing something like "Select * from MyFunc(@a)", the parameter object is created as a Variant (even though the UDF...
    5. example for using sql variant
      Hi! Can anyone tell me a good example where to use the datatype sql variant? Thanks Jan
  3. #2

    Default OLE Variant

    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?


    Ken Brown Guest

  4. #3

    Default Re: OLE Variant

    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

    "Brian Helterline" <brian_helterline@hp.com> wrote in message
    news:3f01faba$1@usenet01.boi.hp.com...
    > Hi Ken,
    >
    > "Ken Brown" <ken.brown@dialwrap.co.uk> wrote in message
    > news:bdshcf$t60$1@news6.svr.pol.co.uk...
    > > 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
    >
    >

    Ken Brown Guest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139