I got a small problem with .xls files. I am parsing a file. Its good completely except the merged rows using for headers(already merged in template) getting emerged after parsing & saving. I am not doing anything for that merged rows. I am just writing in below rows. Then why they are emerged????

My template is like this. Merged & center (3 rows) for each type of error.

------------------------------------------------ User Errors | Netowrk Errors | System Error | ------------------------------------------------

After parsing its getting emerging the cells like this.

------------------------------------------------ User| | | Netowrk | | | System | | | ------------------------------------------------

I am writing the code like this. Here I am not writing anything into that rows.

#!/usr/bin/perl use strict; use warnings; use DBI; use Spreadsheet::ParseExcel; use Spreadsheet::ParseExcel::SaveParser; my $date=$ARGV[1]; #yymmdd my $hour=$ARGV[0]; #06 $date or $date=`date --date='1 day ago' +%Y%m%d`; chomp $date; chomp $hour; my $db_name = "ravi"; my $table = "CDR"; my $sub_table = "Submission_Failures"; my $del_table = "Delivery_Failures"; my $host = "xxx.xx.x.xxx"; my $command = "cp /root/prac/CDR/CDR.xls /root/prac/CDR/CDR_Report_20$ +date$hour.xls"; print $command; `$command`; sub NULL_count { my $type = $_[0]; my @temp_array; my $error_db = DBI->connect("DBI:mysql:database=$db_name;host= +$host;mysql_socket=/opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","roo +t","", {'RaiseError' => 1}); my $error_sth = $error_db->prepare("SELECT Error_list from err +or_potrait WHERE Date='$date' and Type='$type'"); $error_sth->execute() or die $DBI::errstr; while (my $temp = $error_sth->fetchrow_array()) { push(@temp_array, $temp); } my $temp = @temp_array; foreach my $i ($temp .. 4) { $temp_array[$i] = "NULL"; } $error_sth->finish(); return @temp_array; } my @db_system_errors = NULL_count ("Submission_user_error"); my @db_network_errors = NULL_count ("Submission_ESME_error"); my @db_ESME_errors = NULL_count ("Submission_system_error"); my @db_user_errors = NULL_count ("Submission_network_error"); my @del_user_errors = NULL_count ("Delivery_user_error"); my @del_network_errors = NULL_count ("Delivery_network_error"); my @del_system_errors = NULL_count ("Delivery_system_error"); my @submission_errors = (@db_network_errors,@db_system_errors,@db_ESM +E_errors,@db_user_errors); my @delivery_errors = (@del_user_errors,@del_network_errors,@del_sy +stem_errors); sub error_headers { my $sheet_no = shift; my @array = @_; my $row = 1; my $col = 1; # Open an existing file with SaveParser my $parser = Spreadsheet::ParseExcel::SaveParser->new(); my $template = $parser->Parse("CDR_Report_20$date$hour.xls") o +r die "Cant open xls"; # Get the first worksheet. my $sheet = $template->worksheet($sheet_no); $sheet->AddCell( 1, 0, $date ); foreach my $value (@array) { $sheet->AddCell( $row, $col, $value ); ++$col; } $template->SaveAs("CDR_Report_20$date$hour.xls"); } error_headers (3,@submission_errors); error_headers (4,@delivery_errors); sub parser_excel { my $sql_comm = $_[0]; my $sheet_no = $_[1]; my $row = $_[2]; my $col = $_[3]; my $dbh = DBI->connect("DBI:mysql:database=$db_name;host=$host +;mysql_socket=/opt/lampstack-5.5.27-0/mysql/tmp/mysql.sock","root","" +, {'RaiseError' => 1}); #Selecting the data to fetch my $sth = $dbh->prepare("$sql_comm"); $sth->execute() or die $DBI::errstr; # Open an existing file with SaveParser my $parser = Spreadsheet::ParseExcel::SaveParser->new(); my $template = $parser->Parse("CDR_Report_20$date$hour.xls") o +r die "Cant open xls"; # Get the first worksheet. my $sheet = $template->worksheet($sheet_no); $sheet->AddCell( $_[4], 0, $date ); while (my @row = $sth->fetchrow_array()) { my $Date_db = shift @row; foreach my $value (@row) { $sheet->AddCell( $row, $col, $value ); ++$col; } $row++; $col=0; } $template->SaveAs("CDR_Report_20$date$hour.xls"); $sth->finish(); } parser_excel("Select * from $table where Date = $date and Hour = $hour +",2,1,0,0); parser_excel("Select * from $sub_table where Date = $date and Hour = $ +hour",3,2,0,1); parser_excel("Select * from $del_table where Date = $date and Hour = $ +hour",4,2,0,1);

In reply to After parsing .xls the rows getting emerged by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.