Hi All,
To Moderator :
Sorry i have posted this querry to member rather putting in the forum.
To All:
Problem stmt:
I am reading the data from the excel files & writing its content to another excel file.problem is that everytime it reads data it writes all the content.
i want the script to write the header only once.
output look like this:
in the above output data, i need script to write header only once.
script goes like this :
Can anyone help me on this ???
Sorry again kevin,jeff & moderator !!!!
Regards,
Vijayarl
To Moderator :
Sorry i have posted this querry to member rather putting in the forum.
To All:
Problem stmt:
I am reading the data from the excel files & writing its content to another excel file.problem is that everytime it reads data it writes all the content.
i want the script to write the header only once.
output look like this:
Code:
DD/MM/YYYY HH:MM:SS r/s w/s kr/s kw/s 18/01/2008 18:00:00 0.5 2.9 15 31.5 18/01/2008 18:00:00 5 0 0 0 DD/MM/YYYY HH:MM:SS r/s w/s kr/s kw/s 18/01/2008 18:00:00 0.5 1.9 13 30.5 18/01/2008 18:00:00 2 0 0 0 DD/MM/YYYY HH:MM:SS r/s w/s kr/s kw/s 18/01/2008 18:00:00 0.5 3.9 11 32.5 18/01/2008 18:00:00 0 0 1 0
script goes like this :
Code:
# Build an array of the stats type to be collated
#my @stat_type=split(/:/, $PARAMS{COLLATE_STAT_TYPES});
@stat_type=@uniq;
# 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();
}
Sorry again kevin,jeff & moderator !!!!
Regards,
Vijayarl
Comment