-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
108 lines (77 loc) · 1.99 KB
/
index.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
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* A quick guide for Jafar Ahmed
*
* This script helps to understand how to read xlsx file using PHPExcel library
* specifically reading column wise and row wise
*
* PHP version 5
*
*
* @category php exel report
* @author Original Author <[email protected]>
*
*/
error_reporting(E_ALL);
set_time_limit(0);
date_default_timezone_set('Asia/Dhaka');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>XL Report</title>
</head>
<body>
<?php
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';
$inputFileName = './sampleData/m.xlsx';
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$highestRow = $objPHPExcel->setActiveSheetIndex(0)->getHighestRow();
$highestColumm = $objPHPExcel->setActiveSheetIndex(0)->getHighestColumn();
$columnwiseEx1 = $objPHPExcel->getActiveSheet()->rangeToArray('A1:AC1');
$columnwiseEx2 = $objPHPExcel->getActiveSheet()->rangeToArray('A3:AC3');
//example of getting specific cell value like date
$date_of_report=$objPHPExcel->getActiveSheet()->rangeToArray('E1:F1');
for($i=0; $i<1;$i++){
if($date_of_report[0][$i]!=""){
$rDate=$date_of_report[0][$i];
}
}
echo"<h2>Date: $rDate</h2>";
/*
//column wise reading
for($i=0; $i<20;$i++){
if($columnwiseEx1[0][$i]!=""){
echo $columnwiseEx1[0][$i]." | ";
}
}
echo"<br/>";
for($i=0; $i<20;$i++){
if($columnwiseEx2[0][$i]!=""){
echo $columnwiseEx2[0][$i]." | ";
}
}
*/
echo"<h2>Territory Name</h2>";
///territory name
$ttn = $objPHPExcel->getActiveSheet()->rangeToArray('B5:B2000');
for($i=0; $i<$highestRow;$i++){
if($ttn[$i][0]!=""){
echo $ttn[$i][0]." <br/> ";
}
}
echo"<h2>Territory Code</h2>";
///territory code
$ttc = $objPHPExcel->getActiveSheet()->rangeToArray('C5:C2000');
for($i=0; $i<$highestRow;$i++){
if($ttc[$i][0]!=""){
echo $ttc[$i][0]." <br/> ";
}
}
?>
<body>
</html>