#!/usr/bin/perl –w use strict; use warnings; use Spreadsheet::ParseExcel; use Spreadsheet::WriteExcel; my $FileName = "/Users/Reku/Documents/nfrFinal.xls"; my $parser = Spreadsheet::ParseExcel->new(); # Create a new Excel file my $FileName1 = "/Users/Reku/Documents/nfrOutput2.xls"; my $workbook1 = Spreadsheet::WriteExcel->new($FileName1); # Add a worksheet my $worksheet1 = $workbook1->add_worksheet("NFR"); $worksheet1->write(0,0,"NFR"); $worksheet1->write(0,1,"Keyword"); $worksheet1->write(0,2,"Occurance"); my $workbook = $parser->parse($FileName); my $srs = '/Users/Reku/Documents/SRSSample.doc'; die $parser->error(), ".\n" if ( !defined $workbook ); my $col1=0; my $flag=0; my $attribute=0; my $cell2=0; # Following block is used to Iterate through all worksheets # in the workbook and print the worksheet content for my $worksheet ( $workbook->worksheets() ) { # Find out the worksheet ranges my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range(); my $col=0; for my $col ( $col_min..$row_max ) { for my $row ( $row_min .. $row_max ) { my $count=1; # Return the cell object at $row and $col my $cell = $worksheet->get_cell( $row, $col ); $cell2 = $worksheet->get_cell(0,$col); $attribute = $cell2->value(); $worksheet1->write(0,$col,$attribute); next unless $cell; my $value =$cell->value(); if($value eq "") { } else { open('FILE',$srs) or die $1; while() { my $String = $_; my @temp=split(' ',$String); foreach my $loop(@temp) { $count++ if($loop =~m/$value/i) } } $col1++; my $match=$cell2->value(); if($count>1) { print "\n$value occured $count time(s) in ur srs,so u should consider $match\n"; #if($match eq $attribute){ $worksheet1->write($count,$col,$value); #} #$worksheet1->write($col1,1,$value); #$worksheet1->write($col1,2,$count); #$col1++; } close(FILE); } } }