Login   Register  
PHP Classes
elePHPant
Icontem

How to merge multiple cells into one

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Excel Writer  >  All threads  >  How to merge multiple cells into one  >  (Un) Subscribe thread alerts  
Subject:How to merge multiple cells into one
Summary:is it possible to merge multiple cells of excel sheet
Messages:3
Author:m vipindas
Date:2012-01-18 12:35:48
Update:2012-05-17 19:12:21
 

  1. How to merge multiple cells into one   Reply   Report abuse  
Picture of m vipindas
m vipindas
2012-01-18 12:35:50
i need to generate an excel report based on the data from database between a date span. the excel file is generated successfuly.

but now i need to give an heading to the file, so need to merge the cells, can anybody tell me is it possible using this package.

thanks

  2. Re: How to merge multiple cells into one   Reply   Report abuse  
Picture of Joao Rolim
Joao Rolim
2012-04-10 18:50:38 - In reply to message 1 from m vipindas
I created a new function in the class, which takes as parameters the array and the number of merged cells.

#--------------

function writeLineMerge($line_arr, $merge){
if($this->state!="OPENED"){
$this->error="Error : Please open the file.";
return false;
}
if(!is_array($line_arr)){
$this->error="Error : Argument is not valid. Supply an valid Array.";
return false;
}
fwrite($this->fp,"<tr>");
foreach($line_arr as $col)
fwrite($this->fp,"<td class=xl24 width=64 colspan=$merge>$col</td>");
fwrite($this->fp,"</tr>");
}
#--------------
It's work!

  3. Re: How to merge multiple cells into one   Reply   Report abuse  
Picture of Chad Beninati
Chad Beninati
2012-05-17 19:12:21 - In reply to message 2 from Joao Rolim
Try this out to keep CSS support while merging cells:

function writeLineMerge($line_arr, $merge, $css = NULL){
if($this->state != "OPENED"){
$this->error="Error : Please open the file.";
return false;
}
if(!is_array($line_arr)){
$this->error = "Error : Argument is not valid. Supply an valid Array.";
return false;
}
if($css!=NULL)
{
$cssStr = $this->getCssString($css);
}

fwrite($this->fp,"<tr>");
foreach($line_arr as $col)
fwrite($this->fp,"<td class=xl24 width=64 colspan=$merge $cssStr>$col</td>");
fwrite($this->fp,"</tr>");
}