"Fossies" - the Fresh Open Source Software Archive

Member "php_writeexcel-0.3.0/example-merge2.php" (1 Nov 2005, 1684 Bytes) of package /linux/www/old/php_writeexcel-0.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "example-merge2.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 set_time_limit(10);
    4 
    5 require_once "class.writeexcel_workbook.inc.php";
    6 require_once "class.writeexcel_worksheet.inc.php";
    7 
    8 $fname = tempnam("/tmp", "merge2.xls");
    9 $workbook = &new writeexcel_workbook($fname);
   10 $worksheet = &$workbook->addworksheet();
   11 
   12 # Set the column width for columns 2 and 3
   13 $worksheet->set_column(1, 2, 20);
   14 
   15 # Set the row height for row 2
   16 $worksheet->set_row(2, 30);
   17 
   18 # Create a border format
   19 $border1 =& $workbook->addformat();
   20 $border1->set_color('white');
   21 $border1->set_bold();
   22 $border1->set_size(15);
   23 $border1->set_pattern(0x1);
   24 $border1->set_fg_color('green');
   25 $border1->set_border_color('yellow');
   26 $border1->set_top(6);
   27 $border1->set_bottom(6);
   28 $border1->set_left(6);
   29 $border1->set_align('center');
   30 $border1->set_align('vcenter');
   31 $border1->set_merge(); # This is the key feature
   32 
   33 # Create another border format. Note you could use copy() here.
   34 $border2 =& $workbook->addformat();
   35 $border2->set_color('white');
   36 $border2->set_bold();
   37 $border2->set_size(15);
   38 $border2->set_pattern(0x1);
   39 $border2->set_fg_color('green');
   40 $border2->set_border_color('yellow');
   41 $border2->set_top(6);
   42 $border2->set_bottom(6);
   43 $border2->set_right(6);
   44 $border2->set_align('center');
   45 $border2->set_align('vcenter');
   46 $border2->set_merge(); # This is the key feature
   47 
   48 # Only one cell should contain text, the others should be blank.
   49 $worksheet->write      (2, 1, "Merged Cells", $border1);
   50 $worksheet->write_blank(2, 2,                 $border2);
   51 
   52 $workbook->close();
   53 
   54 header("Content-Type: application/x-msexcel; name=\"example-merge2.xls\"");
   55 header("Content-Disposition: inline; filename=\"example-merge2.xls\"");
   56 $fh=fopen($fname, "rb");
   57 fpassthru($fh);
   58 unlink($fname);
   59 
   60 ?>