-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
84 lines (74 loc) · 2.38 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
<?php
if(!isset($_GET['sutun1']) ||!isset($_GET['sutun2']) ){
Echo "<pre>
GET Deşişkenleri<br>
sutun1= Hangi Sutundaki veriyi okuyacaksanız Onun Harf Kodu<br>
sutun2= Hangi Sutundaki veriyi okuyacaksanız Onun Harf Kodu<br>
cikti=Çıktı Formatı json veya txt olabilir<br>
kaydet= veriyi kaydetmek için 1 varsayılan değeri False yani 0 dır<br>
isim=kaydedilecek dosya dosya adi varsayilan file dir<br>
Örnek Kullanım:<a href='index.php?sutun1=A&sutun2=B&cikti=json&isim=dosya_Adi&kaydet=0'>index.php?sutun1={A}&sutun2={B}&cikti={json}&isim={dosya_Adi}&kaydet={0}</a></pre>";
}else{
require_once "Classes/PHPExcel.php";
$tmpfname = "tablo.xlsx";
$excelReader = PHPExcel_IOFactory::createReaderForFile($tmpfname);
$excelObj = $excelReader->load($tmpfname);
$worksheet = $excelObj->getSheet(0);//
$lastRow = $worksheet->getHighestRow();
$data = [];
for ($row = 2; $row <= $lastRow; $row++) {
$data[] = [
'KOD' => $worksheet->getCell($_GET['sutun1'].$row)->getValue(),
'STRING' => $worksheet->getCell($_GET['sutun2'].$row)->getValue()
];
}
$jsonObj= json_encode($data,JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$uzanti="";
if(isset($_GET['cikti'])){
if($_GET['cikti']=="json"){
$uzanti=".json";
if(isset($_GET['kaydet'])){
if($_GET['kaydet']==1){
if(isset($_GET['isim'])){
$isim=$_GET['isim'];
}else{
$isim="file";
}
header("Content-Disposition: attachment; filename=".$isim.$uzanti);
}
}
header('Content-Type: application/json');
echo $jsonObj;
}else{
$uzanti=".txt";
if(isset($_GET['kaydet'])){
if($_GET['kaydet']==1){
if(isset($_GET['isim'])){
$isim=$_GET['isim'];
}else{
$isim="file";
}
header("Content-Disposition: attachment; filename=".$isim.$uzanti);
}
}
header("Content-type: text/plain");
// echo "txt formata çevir";
$data = json_decode($jsonObj, TRUE);
foreach ($data as $itinerary) {
echo $itinerary["KOD"].' "'.$itinerary["STRING"].'"'.PHP_EOL;
}
}
}
//Kaydetme
if(isset($_GET['kaydet'])){
if($_GET['kaydet']==1){
if(isset($_GET['isim'])){
$isim=$_GET['isim'];
}else{
$isim="file";
}
header("Content-Disposition: attachment; filename=".$isim.$uzanti);
}
}
}// Ana Koşul
?>