in reply to Increase speed of nested loop Win32 Excel Manipulation

As swl suggested, you can read/write data as a range.

#!perl use strict; use Win32::OLE; use Win32::OLE::Const "Microsoft Excel"; use Data::Dump 'pp'; $Win32::OLE::Warn = 3; my $Excel =Win32::OLE->new('Excel.Application'); $Excel->{Visible} = 1; my $Book = $Excel->Workbooks->Open('c:/temp/Book1.xlsx'); my $Sheet = $Book->Worksheets("Sheet1"); my $begincol = 2; my $beginrow = 6; # B6 my $endcol = 4; my $endrow = 10;# D10 my $c1 = $Sheet->Cells($beginrow,$begincol); my $c2 = $Sheet->Cells($endrow,$endcol); my $data = $Sheet->Range($c1,$c2)->Value; pp $data; $Sheet->Range("A16:C20")->{'Value'} = $data; $Excel->Quit(); undef $Excel;
poj

Replies are listed 'Best First'.
Re^2: Increase speed of nested loop Win32 Excel Manipulation
by davies (Monsignor) on Feb 17, 2019 at 09:16 UTC

    ++. Even in VBA, this sort of IO is very slow & the docs recommend this approach.

    Regards,

    John Davies