MoodyDreams999 has asked for the wisdom of the Perl Monks concerning the following question:
Input:use Spreadsheet::ParseXLSX; use Excel::Writer::XLSX; my $in_file = "Input.xlsx"; my $out_file = "Output.xlsx"; # Read in all rows from existing file my $rows = read_excel($in_file); my $count = 0; # Write the updated rows to new file my $col_num = 2; write_excel($out_file, $rows, $col_num); ++$count; sub read_excel { my ( $file, $sheet ) = @_; $sheet ||= 0; my $parser = Spreadsheet::ParseXLSX->new(); my $workbook = $parser->parse($file); if ( not defined $workbook ) { die $parser->error; } my $worksheet = $workbook->worksheet($sheet); my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range(); my @rows; for my $row ( $row_min .. $row_max ) { my @cells; for my $col ( $col_min .. $col_max ) { my $cell = $worksheet->get_cell( $row, $col ); if (not $cell) { push(@cells,''); next; } my $value = $cell->value(); push(@cells,$value); } push(@rows,\@cells); } return \@rows; } sub write_excel { my ( $file, $rows, $col_max ) = @_; my $workbook = Excel::Writer::XLSX->new( $file ); if ( not defined $workbook ) { die "Could not open file: $!"; } my $worksheet = $workbook->add_worksheet(); my $row_num = 0; for my $row ( @$rows ) { for my $col (0 .. $col_max) { $worksheet->write( $row_num, $col, $row->[$col] ); } $row_num++; } $workbook->close(); return; }
program_name enrolled_date_cst Prospect Name Salesperson Client Name Street Address City State Zip Code program_status Termination Date Current Program Length Total Debt Enrolled Verified Debt Amount Unverified Debt Amount Original Debt Without Conditional Debt payment_frequency Original scheduled first draft date First Deposit Date Change Flag First Draft Date First Draft Status Second Draft Date Second Draft Status Third Draft Date Third Draft Status Fourth Draft Date Fourth Draft Status Most Recent Draft Failure Reason Bank Account Status Received in Program Loan Flag OBC Completed Within 2 Hrs Flag Service Entity Name Client Deposit Flag Client Deposit Month
0 BRP-255762 2023-03-21 00Q5d00002ECrhKEAT Tammy Smith Larry Buss Charlestown IN 47111 Enrolled 56 46734 46734 0 46734 Monthly 2023-03-31 N 2023-03-31 Completed 2023-04-15 Completed 2023-05-14 Scheduled 2023-06-14 Scheduled VERIFIED FALSE Y Beyond Finance Yes 2023-03-31
1 BRP-281722 2023-04-25 00Q5d00002FBoa6EAD Dan Tucker Linda Smith Morehead KY 40351 Enrolled 55 42724 42724 0 29439 Monthly 2023-04-27 N 2023-04-27 Completed 2023-05-26 Scheduled 2023-06-26 Scheduled 2023-07-26 Scheduled AUTO_VERIFIED FALSE Y Beyond Finance Yes 2023-04-30output:
program_name enrolled_date_cst Salesperson Client Name Total Debt Enrolled Verified Debt Amount Unverified Debt Amount First Draft Date First Draft status
26 BRP-238848 2023-02-24 Tami Smith MORRIS CLEGG 18461 10315 8146 2023-02-28 Returned
44 BRP-240923 2023-02-28 Tami Smith Paul Brannon 22162 22162 0 2023-03-07 Completed
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Deleting a excel column
by atcroft (Abbot) on May 06, 2023 at 00:21 UTC | |
by MoodyDreams999 (Scribe) on May 08, 2023 at 14:53 UTC | |
Re: Deleting a excel column
by NERDVANA (Priest) on May 10, 2023 at 00:25 UTC |