NewMonk2Perl has asked for the wisdom of the Perl Monks concerning the following question:
Here is the full working code if you want to see it:# This is the code that works $mydata = [["Item", "Category", "Price"], ["Nails", "Hardware", "5.25"], ["Shirt", "Clothing", "23.00"]]; # Write all the data at once... $rng = $xlBook->ActiveSheet->Range("A1:C7"); $rng->{Value} = $mydata; # This is my code that doesn't work because I changed it to an array. @mydata = ("Item", "Category", "Price", "Nails", "Hardware", "5.25", "Shirt", "Clothing", "23.00"); # Write all the data at once... $rng = $xlBook->ActiveSheet->Range("A1:C7"); $rng->{Value} = @mydata;
Thanks, Pauluse Win32::OLE; # Start Excel and make it visible $xlApp = Win32::OLE->new('Excel.Application'); $xlApp->{Visible} = 1; # Create a new workbook $xlBook = $xlApp->Workbooks->Add; # Our data that we will add to the workbook... $mydata = [["Item", "Category", "Price"], ["Nails", "Hardware", "5.25"], ["Shirt", "Clothing", "23.00"], ["Hammer", "Hardware", "16.25"], ["Sandwich", "Food", "5.00"], ["Pants", "Clothing", "31.00"], ["Drinks", "Food", "2.25"]]; # Write all the data at once... $rng = $xlBook->ActiveSheet->Range("A1:C7"); $rng->{Value} = $mydata; print "All done.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OLE write to Excel
by toolic (Bishop) on Jan 20, 2011 at 15:30 UTC | |
by NewMonk2Perl (Sexton) on Jan 20, 2011 at 16:06 UTC | |
by NewMonk2Perl (Sexton) on Jan 20, 2011 at 17:05 UTC | |
by marto (Cardinal) on Jan 20, 2011 at 18:41 UTC | |
by NewMonk2Perl (Sexton) on Jan 20, 2011 at 15:37 UTC | |
by marto (Cardinal) on Jan 20, 2011 at 15:49 UTC | |
by NewMonk2Perl (Sexton) on Jan 20, 2011 at 15:57 UTC | |
by Ratazong (Monsignor) on Jan 20, 2011 at 16:08 UTC | |
by toolic (Bishop) on Jan 20, 2011 at 15:50 UTC |