in reply to Re: Delete entire row without using Win32::OLE
in thread Delete entire row without using Win32::OLE

Thanks CountZero Now i am clear that no other module is available to delete entire row. I need other more information on these. I am working now with Spreadsheet::ParseXLSX to read values(Formatted) like this.

$income = $cell->value();

Is there any other one to read values(formatted). I also read about Spreadsheet::Read which cannot work with formatted values (working with unformatted)

Replies are listed 'Best First'.
Re^3: Delete entire row without using Win32::OLE
by poj (Abbot) on Sep 02, 2015 at 06:33 UTC
    I also read about Spreadsheet::Read which cannot work with formatted values

    What ?

    my @row = Spreadsheet::Read::row ($book->[1], 3) Get full row of formatted values (like $sheet->{A3} .. $sheet->{G3})
    poj

      Sorry poj I missed that. I moved much forward through your suggestions. But i want to EDIT a .xlsx now for that i selected Excel::Writer::XLSX its creating a new file but not editing. Later i used Spreadsheet::ParseExcel::SaveParser which editing .xls files but not .XLSX. What I have to do to edit my .xlsx file(without loosing previous data).

      .

        Please have a look at the documentation of Spreadsheet::ParseExcel::SaveParser. It does not "edit" your file, it loads and then overwrites your excel file. You will have to find out how to alter the data structure and then do that. I've already shown you approaches to that, but you seem to want to avoid these.

        How simple is your spreadsheet ? Does it have merged cells, borders, colors, formulae, graphics, etc ?. If it doesn't try this program which should create a copy.Then either adapt it for your update or explain some more the problem you have.

        #!perl use strict; use Spreadsheet::ParseXLSX; use Excel::Writer::XLSX; use Data::Dump 'pp'; my $file = 'c://temp//Book1'; my @data=(); read_file($file.'.xlsx'); #pp \@data; write_file($file.'_copied.xlsx'); sub read_file { my $file = shift; print "Reading $file\n"; my $parser = Spreadsheet::ParseXLSX->new(); my $wb1 = $parser->parse($file); if ( !defined $wb1 ) { die $parser->error(), ".\n"; } for my $n ( 1 .. $wb1->worksheet_count() ) { my $ws = $wb1->worksheet($n-1); my ( $row_min, $row_max ) = $ws->row_range(); my ( $col_min, $col_max ) = $ws->col_range(); my @tmp = (); for my $row ( $row_min .. $row_max ) { for my $col ( $col_min .. $col_max ) { my $cell = $ws->get_cell( $row, $col ); next unless $cell; push @tmp,join "\t",$row,$col,$cell->value(); } } my $name = $ws->get_name; print "Reading sheet $n $name\n"; push @data,[$name,\@tmp]; } } sub write_file { my $file = shift; print "Creating copy workbook $file\n"; my $wb2 = Excel::Writer::XLSX->new( $file ); for my $n (1..@data){ my $name = $data[$n-1][0]; my $ar = $data[$n-1][1]; print "Adding sheet $n $name\n"; my $ws = $wb2->add_worksheet($name); for (@$ar){ my ($row,$col,$value) = split "\t",$_; $ws->write( $row, $col, $value ); } } $wb2->close(); }
        poj