/home/mjc1/public_html/manage/writeexcel/example-demo.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php

set_time_limit
(10);

require_once 
"class.writeexcel_workbook.inc.php";
require_once 
"class.writeexcel_worksheet.inc.php";

$fname tempnam("/tmp""demo.xls");
$workbook =& new writeexcel_workbook($fname);
$worksheet =& $workbook->addworksheet('Demo');
$worksheet2 =& $workbook->addworksheet('Another sheet');
$worksheet3 =& $workbook->addworksheet('And another');

#######################################################################
#
# Write a general heading
#
$worksheet->set_column('A:B'32);
$heading  =& $workbook->addformat(array(
                                        
bold    => 1,
                                        
color   => 'blue',
                                        
size    => 18,
                                        
merge   => 1,
                                        ));

$headings = array('Features of php_writeexcel''');
$worksheet->write_row('A1'$headings$heading);

#######################################################################
#
# Some text examples
#
$text_format =& $workbook->addformat(array(
                                            
bold    => 1,
                                            
italic  => 1,
                                            
color   => 'red',
                                            
size    => 18,
                                            
font    => 'Comic Sans MS'
                                        
));

$worksheet->write('A2'"Text");
$worksheet->write('B2'"Hello Excel");
$worksheet->write('A3'"Formatted text");
$worksheet->write('B3'"Hello Excel"$text_format);

#######################################################################
#
# Some numeric examples
#
$num1_format =& $workbook->addformat(array(num_format => '$#,##0.00'));
$num2_format =& $workbook->addformat(array(num_format => ' d mmmm yyy'));

$worksheet->write('A4'"Numbers");
$worksheet->write('B4'1234.56);
$worksheet->write('A5'"Formatted numbers");
$worksheet->write('B5'1234.56$num1_format);
$worksheet->write('A6'"Formatted numbers");
$worksheet->write('B6'37257$num2_format);

#######################################################################
#
# Formulae
#
$worksheet->set_selection('B7');
$worksheet->write('A7''Formulas and functions, "=SIN(PI()/4)"');
$worksheet->write('B7''=SIN(PI()/4)');

#######################################################################
#
# Hyperlinks
#
$worksheet->write('A8'"Hyperlinks");
$worksheet->write('B8',  'http://www.php.net/');

#######################################################################
#
# Images
#
$worksheet->write('A9'"Images");
$worksheet->insert_bitmap('B9''php.bmp'168);

#######################################################################
#
# Misc
#
$worksheet->write('A17'"Page/printer setup");
$worksheet->write('A18'"Multiple worksheets");

$workbook->close();

header("Content-Type: application/x-msexcel; name=\"example-demo.xls\"");
header("Content-Disposition: inline; filename=\"example-demo.xls\"");
$fh=fopen($fname"rb");
fpassthru($fh);
unlink($fname);

?>