in reply to Re^2: OLE write to Excel
in thread OLE write to Excel

I am not sure how to get it to use all the rows with just using "\@mydata". I modified the code to work, but it is very inefficient. Can anyone think of a more efficient way to resolve this issue without using a loop? The code is below:
# Our data that we will add to the workbook... @mydata = ("Item", "Category", "Price"); @mydata1 = ("Nails", "Hardware", "5.25"); @mydata2 = ("Shirt", "Clothing", "23.00"); @mydata3 = ("Hammer", "Hardware", "16.25"); @mydata4 = ("Sandwich", "Food", "5.00"); @mydata5 = ("Pants", "Clothing", "31.00"); @mydata6 = ("Drinks", "Food", "2.25"); # Write all the data at once... $rngt = $xlBook->ActiveSheet->Range("A1:C7"); $rng = $xlBook->ActiveSheet->Range("A1:C1"); $rng1 = $xlBook->ActiveSheet->Range("A2:C2"); $rng2 = $xlBook->ActiveSheet->Range("A3:C3"); $rng3 = $xlBook->ActiveSheet->Range("A4:C4"); $rng4 = $xlBook->ActiveSheet->Range("A5:C5"); $rng5 = $xlBook->ActiveSheet->Range("A6:C6"); $rng6 = $xlBook->ActiveSheet->Range("A7:C7"); $rng->{Value} = \@mydata; $rng1->{Value} = \@mydata1; $rng2->{Value} = \@mydata2; $rng3->{Value} = \@mydata3; $rng4->{Value} = \@mydata4; $rng5->{Value} = \@mydata5; $rng6->{Value} = \@mydata6;

Replies are listed 'Best First'.
Re^4: OLE write to Excel
by marto (Cardinal) on Jan 20, 2011 at 18:41 UTC

    Read the code I gave you here, copy it, populate @mydata with all the data you want, run the script.