#!/usr/bin/perl -w use CGI ':standard'; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DateTime::Format::ISO8601 qw( ); use strict; use Spreadsheet::WriteExcel; use lib "/view/sawans1_insert_data/vobs/pp/pptai/api/NightlyDB"; use API; my @test_run_id; my @total_passed; my @date; my $option_type; my $user_input; my $test_run_id; my $test_run_list_ref; my $sdt = DateTime::Format::ISO8601->parse_datetime(param('start_date')); my $edt = DateTime::Format::ISO8601->parse_datetime(param('end_date')); for (my $dt = $sdt->clone(); $dt<=$edt; $dt->add( days => 1 )){ push @date,$dt->ymd(); } $user_input->{pp_branch} = param('pp_branch'); # Create a new Excel workbook my $file = "test_run.xls"; my $workbook = Spreadsheet::WriteExcel->new($file); # Add a worksheet my $worksheet = $workbook->add_worksheet(); # Add and define a format my $format = $workbook->add_format(); # Add a format $format->set_bold(); $format->set_color('red'); $format->set_align('center'); # Write a formatted and unformatted string, row and column notation. my $col = my $row1 = 0; $worksheet->write(0, 0, 'Date', $format); $worksheet->write(0, 1, 'Nightly Web ID', $format); $worksheet->write(0, 2, 'Number Of Tests Passed', $format); my $row = 1; my $i = 0; foreach (@date){ #create hash reference variable for every date in array @date $user_input->{start_date} = $_; $user_input->{end_date} = $_; #Call get_test_run function to create test run list references $test_run_list_ref = &API::get_test_run($user_input); #For each such reference calculate # of objects by addition foreach my $tr_obj (@$test_run_list_ref){ push @total_passed, $tr_obj->number_of_passed(); $tr_obj->nightly_web_id(); $worksheet->write($row,0, $_); $worksheet->write($row,1,$test_run_id[$i]); $worksheet->write($row,2,$total_passed[$i]); $row++; $i++; } } print header( -attachment=>'test_run.xls', );