in reply to Deleting entire row and column

You want to delete an entire row and column of what? The description, "a table", is not specific enough, as it could refer to an HTML table, a table of fields in a plain text file, an Excel table, an array, or something else entirely.

As I'm sure others have suggested to you in the past: Provide provide minimal but sufficient sample input, code, and sample output. We'll take it from there in providing feedback and assistance.


Dave

Replies are listed 'Best First'.
Re^2: Deleting entire row and column
by harishnv (Sexton) on Mar 09, 2018 at 06:48 UTC
    Output file Reg number output 2. Correct 4. Wrong Input file Blank box Blank box Reg number. Output 2. Correct 4. Wrong

    The input file is starting from cell (2,2) But I want to start from (1,1) cell. How to delete the first row and column entirely in excel file.

      XLS or XLSX? What modules do you already use to process the Excel file?

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

        XLS file

      In your programme, create a new worksheet and copy the current data into it as follows:

      Start reading at 1,1 in the original worksheet...
      ...only subtract 1 from both coordinates when you write to the new one, so you achieve the goal.

      After the new worksheet is done writing, delete the original,
      then rename the new one with the name of the original one.

      Cheers, Sören

      Créateur des bugs mobiles - let loose once, run everywhere.
      (hooked on the Perl Programming language)

        use strict; use Spreadsheet::ParseExcel; use Data::Dumper; use Spreadsheet::WriteExcel; my $val=0; my $last_col; my $col=0; my $row=0; my @req_sfr_array; my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse('formatting.xls'); my $row1; my $col1; if ( !defined $workbook ) { die $parser->error(), ".\n"; } my $workbook = Spreadsheet::WriteExcel->new("perl.xls"); $worksheet = $workbook->addworksheet(); foreach my $worksheet ( $workbook->worksheets() ) { my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range(); print DEBUG_LOG "PARSING WORKSHEET:", $worksheet->get_name(), "\n" +; print "\n"; print "ROW_MIN = $row_min, ROW_MAX = $row_max\n"; print "COL_MIN = $col_min, COL_MAX = $col_max\n"; print "\n"; for my $row ( $row_min .. $row_max ) { for my $col ( $col_min .. $col_max ) { my $cell = $worksheet->get_cell( $row, $col ); next unless ($cell);; next unless ($cell->value() =~ /\S+/);; my $val = 0; print "Row, Col = ($row, $col)\n"; print "Value = ", $cell->value(), "\n"; print "\n"; $val = $cell->value(); } if($val eq "Register") { if($row==0 and $col!=0) { $row1=$row; $col1=$col-$col; } elsif($row!=0 and $col==0) { $row1=$row-$row; $col1=$col; } else { $col1=$col-$col; $row1=$row-$row; } $worksheet->write($row1, $col1, "$val"); } else { // i'm not getting what logic i should write to shift the cell + after encountering first cell and shifting } } }

        not able to figure out what to write next, help me out!