Aim9b has asked for the wisdom of the Perl Monks concerning the following question:
The last statement shows how to pass arrays to OLE objects. The Win32::OLE module automatically translates each array reference to a SAFEARRAY, the internal OLE array data type. This translation first determines the maximum nesting level used by the Perl array, and then creates a SAFEARRAY of the same dimension. The @Bars array already contains the data in the correct form for the spreadsheet:my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); $Excel->{SheetsInNewWorkbook} = 1; my $Book = $Excel->Workbooks->Add; my $Sheet = $Book->Worksheets(1); $Sheet->{Name} = 'Candle'; # Insert column titles my $Range = $Sheet->Range("A1:E1"); $Range->{Value} = [qw(Time Open High Low Close)]; $Range->Font->{Bold} = 1; $Sheet->Columns("A:A")->{NumberFormat} = "h:mm"; # Open/High/Low/Close to be displayed in 32nds $Sheet->Columns("B:E")->{NumberFormat} = "# ?/32"; # Add 15 minute data to spreadsheet print "Add data\n"; $Range = $Sheet->Range(sprintf "A2:E%d", 2+$#Bars); $Range->{Value} = \@Bars;
while ($inBuf = <csvFILE>) { chomp($inBuf); ++$line_count; $inBuf =~ s/^\"//; # Take out any LEADING or $inBuf =~ s/\"$//; # TRAILING double quotes # OK, Process this record @fields = split(/\,/,$inBuf); print "\nProcessing record $fields[0]"; push @rows, @fields; ++$item_count; } # End of csvFILE or we reached our Runaway count close csvFILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Array of Arrays
by FunkyMonk (Bishop) on Sep 19, 2007 at 19:35 UTC | |
|
Re: Using Array of Arrays
by GrandFather (Saint) on Sep 19, 2007 at 21:00 UTC | |
by Aim9b (Monk) on Sep 20, 2007 at 13:18 UTC | |
by GrandFather (Saint) on Sep 20, 2007 at 19:16 UTC | |
by Aim9b (Monk) on Sep 21, 2007 at 11:19 UTC | |
by GrandFather (Saint) on Sep 21, 2007 at 21:30 UTC | |
| |
by GrandFather (Saint) on Sep 21, 2007 at 21:43 UTC | |
by Aim9b (Monk) on Sep 24, 2007 at 15:06 UTC | |
|
Re: Using Array of Arrays
by bruceb3 (Pilgrim) on Sep 19, 2007 at 19:38 UTC | |
|
Re: Using Array of Arrays
by Aim9b (Monk) on Sep 19, 2007 at 20:23 UTC |