When trying to insert an empty row using the following code
my $StartRow = "101"; my $StartCol = "1";
$Sheet->Cells($StartRow,$StartCol)->EntireRow->Insert;
Error Occurred: Win32::OLE(0.1709) error 0x800a03ec in METHOD/PROPERTYGET "Cells" at 1_SPNV3G_WSS-MGW_1_0_Chicago.pl line 1732.
Win32::OLE(0.1709) error 0x80010108: "The object invoked has disconnected from its clients" in METHOD/PROPERTYGET "Close" at 1_SPNV3G_WSS-MGW_1_0_Chicago.pl line 6310.
Where as if I give the the values directly, no issue observed.
$Sheet->Cells(101,1)->EntireRow->Insert;
Any thoughts?
P.S. I am referring this thread for Insert row. http://www.perlmonks.org/?node_id=882700
Because, Perl infers the types of variables dynamically. Variables $StartRow
and $StartCol
are considered as strings as you enclosed their assigned values in quotes. Remove the quotes and they'll work, as the 'Cells' method expects integers as arguments. or try
$StartRow = int ($StartRow);
$StartCol = int ($StartCol);
This should work. I encountered this recently while doing this
my ($i, $j) = split (/\s*,\s*/, $address);
print "\n".$sheet->Cells($i, $j)->{Value};
Here the values returned from the split operation were considered as strings. Then I converted them to integers and it worked.
User contributions licensed under CC BY-SA 3.0