Can somebody help me please?
i try to generate an xls(excel) file using this code, all format work fine except the
cell size(width).
can anyone help me how to format the cell width?
</php
.
.
.
$workbook = new Spreadsheet_Excel_Writer();
$format_und =& $workbook->addFormat();
$format_und->setBottom(1);//thick
$format_und->setAlign('center');
$format_und->setHAlign('equal_space');
$format_und->setBold();
$format_und->setVAlign('vcentre');
$format_und->setFgColor('silver');
$format_und->setColor('black');
$format_und->setFontFamily('Arial');
$format_und->setSize(8);
$format_cell =& $workbook->addFormat();
$format_cell->setBottom(1);//thick
$format_cell->setAlign('center');
$format_cell->setHAlign('equal_space');
$format_cell->setVAlign('vcentre');
$format_cell->setPattern(5);
$format_cell->setFgColor('blue');
$format_cell->setFontFamily('Arial');
$format_cell->setSize(8);
$format_reg =& $workbook->addFormat();
$format_reg->setColor('grey');
$format_reg->setFontFamily('Arial');
$format_reg->setSize(8);
$arr = array(
'test'=>$sheet1,
'Names' =>$sheet2,
);
foreach($arr as $wbname=>$rows)
{
$rowcount = count($rows);
$colcount = count($rows[0]);
$worksheet =& $workbook->addWorksheet($wbname);
$worksheet->setColumn(0,0, 6.14);//setColumn(startcol,endcol,float)
$worksheet->setColumn(1,3,15.00);
$worksheet->setColumn(4,4, 8.00);
for( $j=0; $j<$rowcount; $j++ )
{
for($i=0; $i<$colcount;$i++)
{
$fmt =& $format_reg;
if ($j==0)
$fmt =& $format_und;
if (isset($rows[$j][$i]))
{
$col_arr = array(3,4,5,8,9);
foreach($col_arr as $ca){
if($i==$ca && $j==0)
$fmt =& $format_cell;
}
$data=$rows[$j][$i];
$worksheet->write($j, $i, $data, $fmt);
}
}
}
}
$workbook->send('test.xls');
$workbook->close();
?>
thank you in advance.
Sorry for my bad english