Click here to get back home

Perl OLE Excel - STDEVA function

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Perl OLE Excel - STDEVA function Slickuser 05-02-2008
Get Chitika Premium
Posted by Slickuser on May 2, 2008, 8:25 pm
Please log in for more thread options
I try to calculate the standard deviation of average of C2:C35.
But I get random range in the worksheet G$i. It's not showing as:

D2 =STDEVA(C2:C35,D2)
D3 =STDEVA(C2:C35,D3)
.....

It's showing as:

D2 =STDEVA(C2:C35,D2)
D3 =STDEVA(C2:C31,D3)
D4 =STDEVA(C2:C33,D4)
.....

Any one know why? I tried with " " doesn't help and q { } show nothing
since it's like ' '.

Thanks.

        my $lastRowStd = 35;
        my $i=2;
        while($i<=$lastRowStd)
        {
                $Range = $CurrentSheet->Range("G$i");
                $Range-> = qq ;
                $i++;
        }

Posted by Ben Bullock on May 2, 2008, 8:44 pm
Please log in for more thread options
On Fri, 02 May 2008 17:25:22 -0700, Slickuser wrote:

> I try to calculate the standard deviation of average of C2:C35. But I
> get random range in the worksheet G$i. It's not showing as:
>
> D2 =STDEVA(C2:C35,D2)
> D3 =STDEVA(C2:C35,D3)
> .....
>
> It's showing as:
>
> D2 =STDEVA(C2:C35,D2)
> D3 =STDEVA(C2:C31,D3)
> D4 =STDEVA(C2:C33,D4)
> .....
>
> Any one know why? I tried with " " doesn't help and q { } show nothing
> since it's like ' '.

I don't know why, but if I had to debug this,

> Thanks.
>
>         my $lastRowStd = 35;
>         my $i=2;
>         while($i<=$lastRowStd)
>         {

my $cell_value = "=STDEVA(C2:C".$lastRowStd.",D".$i;
print "In: ",$cell_value,"\n";

>                 $Range = $CurrentSheet->Range("G$i"); $Range-> = qq

$Range-> = $cell_value;
print "Excel says: ",$Range->Value,"\n";

>                 ; $i++;
>         }

If you try running the above, what do you get?

Posted by Slickuser on May 3, 2008, 12:44 am
Please log in for more thread options
Thanks Ben.

It was working before. It was my sort method was messing it up.

I tested out with this full code, and my previous and it work too.

use Win32::OLE;
use warnings;
use strict;

        my $Excel = Win32::OLE->new('Excel.Application', 'Quit');
        $Excel-> = 1;
        $Excel-> = 1;

        my $Workbook = $Excel->Workbooks->Add();
        my $CurrentSheet = $Workbook->ActiveSheet;
        my $Range;

        for (my $x=1; $x<= 20; $x++) {
                my $range = $Excel->Range("C".$x);
                my $range2 = $Excel->Range("D".$x);
                $range-> = int(rand(900000));
                $range2-> = int(rand(900000));
        }

        my $lastRowStd = 20;
        my $i=1;
        while($i<=$lastRowStd)
        {
                $Range = $CurrentSheet->Range("G$i");

                my $cell_value = "=STDEVA(C1:C".$lastRowStd.",D".$i.")";
                print "In: ",$cell_value,"\n";

                $Range-> = $cell_value;
                print "Excel says: ",$Range->Value,"\n";

                $i++;
        }

        $Workbook -> Save();


> On Fri, 02 May 2008 17:25:22 -0700, Slickuser wrote:
> > I try to calculate the standard deviation of average of C2:C35. But I
> > get random range in the worksheet G$i. It's not showing as:
>
> > D2 =STDEVA(C2:C35,D2)
> > D3 =STDEVA(C2:C35,D3)
> > .....
>
> > It's showing as:
>
> > D2 =STDEVA(C2:C35,D2)
> > D3 =STDEVA(C2:C31,D3)
> > D4 =STDEVA(C2:C33,D4)
> > .....
>
> > Any one know why? I tried with " " doesn't help and q { } show nothing
> > since it's like ' '.
>
> I don't know why, but if I had to debug this,
>
> > Thanks.
>
> > my $lastRowStd = 35;
> > my $i=2;
> > while($i<=$lastRowStd)
> > {
>
> my $cell_value = "=STDEVA(C2:C".$lastRowStd.",D".$i;
> print "In: ",$cell_value,"\n";
>
> > $Range = $CurrentSheet->Range("G$i"); $Range-> = qq
>
> $Range-> = $cell_value;
> print "Excel says: ",$Range->Value,"\n";
>
> > ; $i++;
> > }
>
> If you try running the above, what do you get?


Similar ThreadsPosted
How to get an Excel cell value that's based on a function using Win32::OLE December 13, 2006, 1:09 am
adding an excel worksheet to a generetad excel file via perl April 17, 2007, 8:38 am
OLE & Excel - Opening causes Excel.exe to hang around April 21, 2005, 1:20 pm
Strange Perl line : Return the result of a function to a function October 24, 2006, 9:19 am
Excel and Perl June 8, 2005, 9:57 pm
Perl and Excel February 8, 2006, 7:55 am
Help Perl and Excel August 16, 2006, 9:28 am
Unix, Perl, IE, and Excel October 23, 2008, 5:21 pm
Mysql -> Perl - MS-Excel ? November 25, 2008, 1:31 pm
Convert excel formula to perl October 25, 2004, 7:38 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap