Removed breaking unit test, originally set up to test xhtml validity throughout the...
[moodle-pu.git] / lib / excel / test.php
blob25a4f1156f0acaa91336facc1dfa3e3b1ffc5a5f
1 <?php
2 //require_once('OLEwriter.php');
3 //require_once('BIFFwriter.php');
4 require_once('Worksheet.php');
5 require_once('Workbook.php');
7 function HeaderingExcel($filename) {
8 header("Content-type: application/vnd.ms-excel");
9 header("Content-Disposition: attachment; filename=$filename" );
10 header("Expires: 0");
11 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
12 header("Pragma: public");
15 // HTTP headers
16 HeaderingExcel('test.xls');
18 // Creating a workbook
19 $workbook = new Workbook("-");
20 // Creating the first worksheet
21 $worksheet1 =& $workbook->add_worksheet('First One');
22 // set the column width
23 $worksheet1->set_column(1, 1, 40);
24 // set the row height
25 $worksheet1->set_row(1, 20);
26 $worksheet1->write_string(1, 1, "This worksheet's name is ".$worksheet1->get_name());
27 $worksheet1->write(2,1,"http://www.phpclasses.org/browse.html/package/767.html");
28 $worksheet1->write_number(3, 0, 11);
29 $worksheet1->write_number(3, 1, 1);
30 $worksheet1->write_string(3, 2, "by four is");
31 $worksheet1->write_formula(3, 3, "=A4 * (2 + 2)");
32 //$worksheet1->write_formula(3, 3, "= SUM(A4:B4)");
33 $worksheet1->write(5, 4, "= POWER(2,3)");
34 $worksheet1->write(4, 4, "= SUM(5, 5, 5)");
35 //$worksheet1->write_formula(4, 4, "= LN(2.71428)");
36 //$worksheet1->write_formula(5, 4, "= SIN(PI()/2)");
38 // Creating the second worksheet
39 $worksheet2 =& $workbook->add_worksheet();
41 // Format for the headings
42 $formatot =& $workbook->add_format();
43 $formatot->set_size(10);
44 $formatot->set_align('center');
45 $formatot->set_color('white');
46 $formatot->set_pattern();
47 $formatot->set_fg_color('magenta');
49 $worksheet2->set_column(0,0,15);
50 $worksheet2->set_column(1,2,30);
51 $worksheet2->set_column(3,3,15);
52 $worksheet2->set_column(4,4,10);
54 $worksheet2->write_string(1,0,"Id",$formatot);
55 $worksheet2->write_string(1,1,"Name",$formatot);
56 $worksheet2->write_string(1,2,"Adress",$formatot);
57 $worksheet2->write_string(1,3,"Phone Number",$formatot);
58 $worksheet2->write_string(1,4,"Salary",$formatot);
60 $worksheet2->write(3,0,"22222222-2");
61 $worksheet2->write(3,1,"John Smith");
62 $worksheet2->write(3,2,"Main Street 100");
63 $worksheet2->write(3,3,"02-5551234");
64 $worksheet2->write(3,4,100);
65 $worksheet2->write(4,0,"11111111-1");
66 $worksheet2->write(4,1,"Juan Perez");
67 $worksheet2->write(4,2,"Los Paltos 200");
68 $worksheet2->write(4,3,"03-5552345");
69 $worksheet2->write(4,4,110);
70 // if you are writing a very long worksheet, you may want to use
71 // write_xxx() functions, instead of write() for performance reasons.
72 $worksheet2->write_string(5,0,"11111111-1");
73 $worksheet2->write_string(5,1,"Another Guy");
74 $worksheet2->write_string(5,2,"Somewhere 300");
75 $worksheet2->write_string(5,3,"03-5553456");
76 $worksheet2->write(5,4,108);
79 // Calculate some statistics
80 $worksheet2->write(7, 0, "Average Salary:");
81 $worksheet2->write_formula(7, 4, "= AVERAGE(E4:E6)");
82 $worksheet2->write(8, 0, "Minimum Salary:");
83 $worksheet2->write_formula(8, 4, "= MIN(E4:E6)");
84 $worksheet2->write(9, 0, "Maximum Salary:");
85 $worksheet2->write_formula(9, 4, "= MAX(E4:E6)");
87 //$worksheet2->insert_bitmap(0, 0, "some.bmp",10,10);
89 $workbook->close();