use strict; use warnings; use Win32::OLE; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add; # Make sure there is precisely 1 sheet for my $nSht (2..$wb->Sheets->{Count}) { $wb->Sheets(2)->Delete; } # Put some data in my $sht = $wb->Sheets(1); $sht->Cells(1, 1)->{Value} = "A"; $sht->Cells(2, 1)->{Value} = "B"; $sht->Cells(3, 1)->{Value} = "C"; # Hide row 2 $sht->Cells(2, 1)->EntireRow->{Hidden} = 1; # Process 3 rows, demonstrating a bug for my $row (1..3) { if ("A" ne $sht->Cells($row, 1)->{Value}) { $sht->Cells($row + 1, 1)->EntireRow->Insert; $sht->Cells($row, 1)->EntireRow->Copy($sht->Cells($row + 1, 1)); } } use feature 'say'; for my $row (1..5) { if ($sht->Cells($row, 1)->EntireRow->{Hidden}) { say "Row $row is hidden"; } }