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
|
<!DOCTYPE html> <html> <head> <?php require_once '../include/head.php'; ?> <?php require_once '../include/checkuser.php'; ?> <?php require_once '../include/Nav_bar.php'; ?> <?php require_once '../include/Classes/PHPExcel.php' ?> <?php require_once '../include/Classes/PHPExcel/IOFactory.php' ?> <?php require_once '../include/Classes/PHPExcel/Writer/Excel2007.php' ?> <script> $(function() { $('.date-picker').datetimepicker({pickTime: false}); }); </script> </head> <body> <?php if (isset($_POST['go'])) { $A1 = $_POST['A1']; $A2 = $_POST['A2']; $name = $_POST['name']; $PHPExcel = new PHPExcel(); $PHPExcel->getProperties()->setCreator("ChiuChunOn"); $PHPExcel->getProperties()->setTitle("Receipt_Test"); $PHPExcel->getProperties()->setDescription("Test document");
$PHPExcel->setActiveSheetIndex(0); $PHPExcel->getActiveSheet()->setCellValue('A1', $A1); $PHPExcel->getActiveSheet()->setCellValue('B1', $A2); $PHPExcel->getActiveSheet()->setCellValue('C1', 'ngkldfnbdljfkbnldxbnxf;lndblxk.bxfbdmlxbndflxbdx'); $PHPExcel->getActiveSheet()->setCellValue('C2', 'haha...sdvnlkdlsvahfvionjdslnvdlnkbmlflbgobomflkblngflnbfgnbgfnlbodnfogndjgofdgojfdogdfg'); $PHPExcel->getActiveSheet()->setCellValue('D1', 'haha'); PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT); foreach (range('A', 'D') as $columnID) { $PHPExcel->getActiveSheet()->getColumnDimension($columnID) ->setAutoSize(true); } $PHPExcelWriter = PHPExcel_IOFactory::createWriter($PHPExcel, 'Excel5'); $PHPExcelWriter->save('' . $name . '.xls'); @header("Content-type: application/force-download"); @header("Content-Disposition: attachment; filename=\"'$name'.xls\""); @header("Content-Length: " . filesize($name . '.xls')); } ?> <!-- line between nav bar and content --> <div class="text-right"> <ul class="breadcrumb"> <li class="active">Receipt</li> </ul> </div> <!-- line between nav bar and content --> <div class="container-fluid pathways-container"> <div> <table border="0" width="100%"> <tr> <td><h3>Receipt</h3></td> </tr> </table> </div> <div class="pathways-search"> <form id="search_form" class="form-inline" action="" method="POST"> <div class="pathways-inline-block"> <label class="" id="A1" name="lableofname">Name</label> <input type="text" name="name"> </div> <br> <div class="pathways-inline-block"> <label class="" id="A1" name="lableofA1">Money</label> <input type="text" name="A1"> </div> <br> <div class="pathways-inline-block"> <label class="" id="A2" name="lableofA2">A2</label> <input type="text" name="A2"> </div> <div class="pathways-inline-block"> <button class="btn" name="go" value="go" style="margin-left:30px" type="submit">GO</button> </div> </form> </div> <!-- /container --> </body> </html>
|