|
 |
|
ทำการ export file excel อยากจะให้ไฟล์ที่ export ไปอยู่ในโฟลเดอร์ที่กำหนด อย่างไรค่ะ |
|
 |
|
|
 |
 |
|
ทำการ export file excel
อยากจะให้ไฟล์ที่ export ไปอยู่ในโฟลเดอร์ที่กำหนด อย่างไรค่ะ
Code (PHP)
public function exportXLS(){
function filterData(&$str)
{
$str = htmlspecialchars_decode($str);
$str = preg_replace("/\t/", "", $str);
$str = preg_replace("/\r?\n/", "", $str);
$str = str_replace('\r','',$str);
$str = str_replace('\n','',$str);
$str = str_replace(',','',$str);
}
$data = $this->home_model->customer_tech_call_csv();
// file name for download
$fileName = "test" . date('Ymd') . ".xls";
// headers for download
//header("Content-Disposition: attachment; filename=\"$fileName\"");
header("Content-Type: application/vnd.ms-excel");
header("Content-Type: text/html; charset=utf-8");
$file_url = ('./doc/xls/'.$fileName);
file_put_contents($file_url,$fileName);
$header = array("Contact type","Cust Problem");
$flag = false;
$bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) );
foreach($data as $row) {
if(!$flag) {
// display column names as first row
echo implode(",", $header) . "\n";
$flag = true;
}
// filter data
array_walk($row, 'filterData');
//echo iconv('UTF-8', 'TIS-620', implode(",", $row)) . "\n";
echo implode(",",array(
iconv('UTF-8', 'TIS-620', $row['contact_type']),
iconv('UTF-8', 'TIS-620', $row['cust_problem']) )). "\n";
//var_dump ($row);
}
}
Tag : PHP, MySQL, CodeIgniter

|
|
 |
 |
 |
 |
Date :
2018-04-03 16:25:14 |
By :
Baitong_ch |
View :
1455 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
กำหนดตรงนี้ได้เลยครับ ใส่ path ให้ถูกก็พอ
Code (PHP)
$file_url = ('./doc/xls/'.$fileName);
|
 |
 |
 |
 |
Date :
2018-04-04 08:59:19 |
By :
mongkon.k |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนนี้ไฟล์ไปบันทึกถูกที่แล้วค่ะ แต่ข้อมูลไม่มาด้วย (ในไฟล์ excel) จะต้องทำอย่างไรหรอค่ะ

|
 |
 |
 |
 |
Date :
2018-04-04 11:19:32 |
By :
Baitong_ch |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|