"Fossies" - the Fresh Open Source Software Archive

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

    1 <?php
    2 
    3 require_once "class.writeexcel_workbook.inc.php";
    4 require_once "class.writeexcel_worksheet.inc.php";
    5 
    6 $fname = tempnam("/tmp", "textwrap.xls");
    7 $workbook = &new writeexcel_workbook($fname);
    8 $worksheet = &$workbook->addworksheet();
    9 
   10 # Set the column width for columns 1, 2 and 3
   11 $worksheet->set_column(1, 1, 24);
   12 $worksheet->set_column(2, 2, 34);
   13 $worksheet->set_column(3, 3, 34);
   14 
   15 # Set the row height for rows 1, 4, and 6. The heigt of row 2 will adjust
   16 # automatically to fit the text.
   17 #
   18 $worksheet->set_row(0, 30);
   19 $worksheet->set_row(3, 40);
   20 $worksheet->set_row(5, 80);
   21 
   22 # No newlines
   23 $str1  = "For whatever we lose (like a you or a me) ";
   24 $str1 .= "it's always ourselves we find in the sea";
   25 
   26 # Embedded newlines
   27 $str2  = "For whatever we lose\n(like a you or a me)\n";
   28 $str2 .= "it's always ourselves\nwe find in the sea";
   29 
   30 
   31 # Create a format for the column headings
   32 $header =& $workbook->addformat();
   33 $header->set_bold();
   34 $header->set_font("Courier New");
   35 $header->set_align('center');
   36 $header->set_align('vcenter');
   37 
   38 # Create a "vertical justification" format
   39 $format1 =& $workbook->addformat();
   40 $format1->set_align('vjustify');
   41 
   42 # Create a "text wrap" format
   43 $format2 =& $workbook->addformat();
   44 $format2->set_text_wrap();
   45 
   46 # Write the headers
   47 $worksheet->write(0, 1, "set_align('vjustify')", $header);
   48 $worksheet->write(0, 2, "set_align('vjustify')", $header);
   49 $worksheet->write(0, 3, "set_text_wrap()", $header);
   50 
   51 # Write some examples
   52 $worksheet->write(1, 1, $str1, $format1);
   53 $worksheet->write(1, 2, $str1, $format1);
   54 $worksheet->write(1, 3, $str2, $format2);
   55 
   56 $worksheet->write(3, 1, $str1, $format1);
   57 $worksheet->write(3, 2, $str1, $format1);
   58 $worksheet->write(3, 3, $str2, $format2);
   59 
   60 $worksheet->write(5, 1, $str1, $format1);
   61 $worksheet->write(5, 2, $str1, $format1);
   62 $worksheet->write(5, 3, $str2, $format2);
   63 
   64 $workbook->close();
   65 
   66 header("Content-Type: application/x-msexcel; name=\"example-textwrap.xls\"");
   67 header("Content-Disposition: inline; filename=\"example-textwrap.xls\"");
   68 $fh=fopen($fname, "rb");
   69 fpassthru($fh);
   70 unlink($fname);
   71 
   72 ?>