"Fossies" - the Fresh Open Source Software Archive 
Member "php_writeexcel-0.3.0/example-demo.php" (1 Nov 2005, 3078 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-demo.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", "demo.xls");
9 $workbook =& new writeexcel_workbook($fname);
10 $worksheet =& $workbook->addworksheet('Demo');
11 $worksheet2 =& $workbook->addworksheet('Another sheet');
12 $worksheet3 =& $workbook->addworksheet('And another');
13
14 #######################################################################
15 #
16 # Write a general heading
17 #
18 $worksheet->set_column('A:B', 32);
19 $heading =& $workbook->addformat(array(
20 bold => 1,
21 color => 'blue',
22 size => 18,
23 merge => 1,
24 ));
25
26 $headings = array('Features of php_writeexcel', '');
27 $worksheet->write_row('A1', $headings, $heading);
28
29 #######################################################################
30 #
31 # Some text examples
32 #
33 $text_format =& $workbook->addformat(array(
34 bold => 1,
35 italic => 1,
36 color => 'red',
37 size => 18,
38 font => 'Comic Sans MS'
39 ));
40
41 $worksheet->write('A2', "Text");
42 $worksheet->write('B2', "Hello Excel");
43 $worksheet->write('A3', "Formatted text");
44 $worksheet->write('B3', "Hello Excel", $text_format);
45
46 #######################################################################
47 #
48 # Some numeric examples
49 #
50 $num1_format =& $workbook->addformat(array(num_format => '$#,##0.00'));
51 $num2_format =& $workbook->addformat(array(num_format => ' d mmmm yyy'));
52
53 $worksheet->write('A4', "Numbers");
54 $worksheet->write('B4', 1234.56);
55 $worksheet->write('A5', "Formatted numbers");
56 $worksheet->write('B5', 1234.56, $num1_format);
57 $worksheet->write('A6', "Formatted numbers");
58 $worksheet->write('B6', 37257, $num2_format);
59
60 #######################################################################
61 #
62 # Formulae
63 #
64 $worksheet->set_selection('B7');
65 $worksheet->write('A7', 'Formulas and functions, "=SIN(PI()/4)"');
66 $worksheet->write('B7', '=SIN(PI()/4)');
67
68 #######################################################################
69 #
70 # Hyperlinks
71 #
72 $worksheet->write('A8', "Hyperlinks");
73 $worksheet->write('B8', 'http://www.php.net/');
74
75 #######################################################################
76 #
77 # Images
78 #
79 $worksheet->write('A9', "Images");
80 $worksheet->insert_bitmap('B9', 'php.bmp', 16, 8);
81
82 #######################################################################
83 #
84 # Misc
85 #
86 $worksheet->write('A17', "Page/printer setup");
87 $worksheet->write('A18', "Multiple worksheets");
88
89 $workbook->close();
90
91 header("Content-Type: application/x-msexcel; name=\"example-demo.xls\"");
92 header("Content-Disposition: inline; filename=\"example-demo.xls\"");
93 $fh=fopen($fname, "rb");
94 fpassthru($fh);
95 unlink($fname);
96
97 ?>