Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

RFC Tutorial - Deleting Excel Rows, Columns and Sheets

by davies (Vicar)
on Feb 06, 2012 at 21:49 UTC ( #952167=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
                                      $sht->Cells(2, 2)->{Value} = 'b';
    $sht->Cells(3, 1)->{Value} = 'c'; $sht->Cells(3, 2)->{Value} = 'c';
    $sht->Cells(1, 2)->Delete({Shift=>xlUp});
    
  2. or download this
    use strict;
    use warnings;
    ...
                                      $sht->Cells(2, 2)->{Value} = 'b';
    $sht->Cells(3, 1)->{Value} = 'c'; $sht->Cells(3, 2)->{Value} = 'c';
    $sht->Cells(1, 2)->EntireRow->Delete;
    
  3. or download this
    use strict;
    use warnings;
    ...
        my $cell = $sht->Cells($count, 2);
        if (!defined $cell->{Value}) { $cell->EntireRow->Delete; } 
    }
    
  4. or download this
    use strict;
    use warnings;
    ...
        my $cell = $sht->Cells($count, 2);
        if (!defined $cell->{Value}) {$cell->EntireRow->Delete} 
    }
    
  5. or download this
    use strict;
    use warnings;
    ...
    $xl->{SheetsInNewWorkbook} = $nShtsOld;
    
    $wb->Sheets(1)->Delete;
    
  6. or download this
    use strict;
    use warnings;
    ...
    for my $nSht(2..3) {
        $wb->Sheets($nSht)->Delete;
    }
    
  7. or download this
    use strict;
    use warnings;
    ...
    for (my $nSht = 3; 1 < $nSht; $nSht--) {
        $wb->Sheets($nSht)->Delete;
    }
    
  8. or download this
    use strict;
    use warnings;
    ...
    for my $nSht (2..$wb->Sheets->{Count}) {
        $wb->Sheets(2)->Delete;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://952167]
Approved by ww
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2015-07-29 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls