"Fossies" - the Fresh Open Source Software Archive

Member "php_writeexcel-0.3.0/example-panes.php" (1 Nov 2005, 3190 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-panes.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 # Example of using the WriteExcel module to create worksheet panes.
    4 #
    5 # reverse(''), May 2001, John McNamara, jmcnamara@cpan.org
    6 
    7 # PHP port by Johann Hanne, 2005-11-01
    8 
    9 set_time_limit(10);
   10 
   11 require_once "class.writeexcel_workbook.inc.php";
   12 require_once "class.writeexcel_worksheet.inc.php";
   13 
   14 $fname = tempnam("/tmp", "panes.xls");
   15 $workbook = &new writeexcel_workbook($fname);
   16 
   17 $worksheet1 =& $workbook->addworksheet('Panes 1');
   18 $worksheet2 =& $workbook->addworksheet('Panes 2');
   19 $worksheet3 =& $workbook->addworksheet('Panes 3');
   20 $worksheet4 =& $workbook->addworksheet('Panes 4');
   21 
   22 # Frozen panes
   23 $worksheet1->freeze_panes(1, 0); # 1 row
   24 $worksheet2->freeze_panes(0, 1); # 1 column
   25 $worksheet3->freeze_panes(1, 1); # 1 row and column
   26 
   27 # Un-frozen panes. The divisions must be specified in terms of row and column
   28 # dimensions. The default row height is 12.75 and the default column width
   29 # is 8.43
   30 #
   31 $worksheet4->thaw_panes(12.75, 8.43, 1, 1); # 1 row and column
   32 
   33 
   34 
   35 
   36 #######################################################################
   37 #
   38 # Set up some formatting and text to highlight the panes
   39 #
   40 
   41 $header =& $workbook->addformat();
   42 $header->set_color('white');
   43 $header->set_align('center');
   44 $header->set_align('vcenter');
   45 $header->set_pattern();
   46 $header->set_fg_color('green');
   47 
   48 $center =& $workbook->addformat();
   49 $center->set_align('center');
   50 
   51 
   52 #######################################################################
   53 #
   54 # Sheet 1
   55 #
   56 
   57 $worksheet1->set_column('A:I', 16);
   58 $worksheet1->set_row(0, 20);
   59 $worksheet1->set_selection('C3');
   60 
   61 for ($i=0;$i<=8;$i++) {
   62     $worksheet1->write(0, $i, 'Scroll down', $header);
   63 }
   64 
   65 for ($i=1;$i<=100;$i++) {
   66     for ($j=0;$j<=8;$j++) {
   67         $worksheet1->write($i, $j, $i+1, $center);
   68     }
   69 }
   70 
   71 
   72 #######################################################################
   73 #
   74 # Sheet 2
   75 #
   76 
   77 $worksheet2->set_column('A:A', 16);
   78 $worksheet2->set_selection('C3');
   79 
   80 for ($i=0;$i<=49;$i++) {
   81     $worksheet2->set_row($i, 15);
   82     $worksheet2->write($i, 0, 'Scroll right', $header);
   83 }
   84 
   85 for ($i=0;$i<=49;$i++) {
   86     for ($j=1;$j<=25;$j++) {
   87         $worksheet2->write($i, $j, $j, $center);
   88     }
   89 }
   90 
   91 
   92 #######################################################################
   93 #
   94 # Sheet 3
   95 #
   96 
   97 $worksheet3->set_column('A:Z', 16);
   98 $worksheet3->set_selection('C3');
   99 
  100 for ($i=1;$i<=25;$i++) {
  101     $worksheet3->write(0, $i, 'Scroll down',  $header);
  102 }
  103 
  104 for ($i=1;$i<=49;$i++) {
  105     $worksheet3->write($i, 0, 'Scroll right', $header);
  106 }
  107 
  108 for ($i=1;$i<=49;$i++) {
  109     for ($j=1;$j<=25;$j++) {
  110         $worksheet3->write($i, $j, $j, $center);
  111     }
  112 }
  113 
  114 
  115 #######################################################################
  116 #
  117 # Sheet 4
  118 #
  119 
  120 $worksheet4->set_selection('C3');
  121 
  122 for ($i=1;$i<=25;$i++) {
  123     $worksheet4->write(0, $i, 'Scroll', $center);
  124 }
  125 
  126 for ($i=1;$i<=49;$i++) {
  127     $worksheet4->write($i, 0, 'Scroll', $center);
  128 }
  129 
  130 for ($i=1;$i<=49;$i++) {
  131     for ($j=1;$j<=25;$j++) {
  132         $worksheet4->write($i, $j, $j, $center);
  133     }
  134 }
  135 
  136 $workbook->close();
  137 
  138 header("Content-Type: application/x-msexcel; name=\"example-panes.xls\"");
  139 header("Content-Disposition: inline; filename=\"example-panes.xls\"");
  140 $fh=fopen($fname, "rb");
  141 fpassthru($fh);
  142 unlink($fname);
  143 
  144 ?>