Hi Everyone,
Am trying to collate the individual xls files into a single xls file.i have written this code.
<b>Problem is :</b>
with this line (line no 54)
As soon this line get executed, system stops execution & give the message that it could not open the file<br>
but the required file is getting created with just the file name.xls not with full file name-date.xls
ex: it creates sar-u.xls file but not with sar-u-20080118-1800.xls<br>
i don't know where am doing mistake in this line<br>
can anyone help me why is it not creating the file with full name ???<br>
Regards,<br>
Vijayarl
Am trying to collate the individual xls files into a single xls file.i have written this code.
Code:
use strict;
use Spreadsheet::WriteExcel;
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel::Big;
my $consol_rows=0;
my $token;
my $file_name;
my $config_file = "C:\\Perl_Tools_ICON_PROD_SVAP_2_15\\config.txt";
my %PARAMS;
my $CONFIG = "";
my $MMSS = "";
# parse the configuration text file entries into PARAMS associative array
open (CONFIGFILE, "$config_file") or die;
while (<CONFIGFILE>) {
chomp;
if($_!~ /QUIT_TXT/ ){
if ( ! ( $_ =~ /^#/ )) {
$CONFIG = $CONFIG . $_ . " ";
}
}
else{
last;
}
}
close (CONFIGFILE);
%PARAMS = split(/\s+/, $CONFIG);
# Build an array of the stats type to be collated
my @stat_type=split(/:/, $PARAMS{COLLATE_STAT_TYPES});
# for each of the stats type, read the xls of each hour and write into a consolidated xls.
foreach my $stat_type_token (@stat_type){
my $con_wb = Spreadsheet::WriteExcel::Big->new("$PARAMS{INPUT_FILE_BASE_PATH}$stat_type_token.xls");
my $con_excel = $con_wb->add_worksheet();
my $con_row = 0;
my @stat_files=split(/:/, $PARAMS{COLLATE_YYYYMMDD_HH});
foreach my $stat_files_token (@stat_files) {
my $source_xl_name = $PARAMS{INPUT_FILE_BASE_PATH}.$stat_type_token."-".$stat_files_token.".xls";
my $source_excel = new Spreadsheet::ParseExcel;
my $source_book = $source_excel->Parse($source_xl_name) or die "Could not open source Excel file $source_xl_name !";
my $source_sheet = $source_book->{Worksheet}[0];
print "Processing $stat_type_token-$stat_files_token xls please wait\n";
foreach my $row_index ($source_sheet->{MinRow} .. $source_sheet->{MaxRow}) {
my $con_col = 0;
foreach my $col_index ($source_sheet->{MinCol} .. $source_sheet->{MaxCol}) {
my $source_cell = $source_sheet->{Cells}[$row_index][$col_index];
if (defined $source_cell) {
$con_excel->write($con_row, $con_col, $source_cell->Value );
}
$con_col++;
}
$con_row++;
$consol_rows++;
# max row count in Excel is 65536 rows.
# open a new sheet if the max row is reached.
if ( $consol_rows > 65000 ) {
$consol_rows = 0;
$con_row = 0;
$con_col = 0;
$con_excel = $con_wb->add_worksheet();
}
}
}
$con_wb->close();
}
print "Processing Done. Time to analyse\n";
with this line (line no 54)
Code:
my $source_book = $source_excel->Parse($source_xl_name) or die "Could not open source Excel file $source_xl_name !";
but the required file is getting created with just the file name.xls not with full file name-date.xls
ex: it creates sar-u.xls file but not with sar-u-20080118-1800.xls<br>
i don't know where am doing mistake in this line<br>
Code:
my $source_xl_name = $PARAMS{INPUT_FILE_BASE_PATH}.$stat_type_token."-".$stat_files_token.".xls";
Regards,<br>
Vijayarl
Comment