update
This commit is contained in:
47
inc/Hura8/System/Export.php
Normal file
47
inc/Hura8/System/Export.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
//used to export content to download
|
||||
namespace Hura8\System;
|
||||
|
||||
|
||||
class Export
|
||||
{
|
||||
public function export($content, $file_name, $type)
|
||||
{
|
||||
if($type=='xls' || $type=='xlsx') {
|
||||
$this->setHeaderXLS($file_name);
|
||||
}
|
||||
else if($type=='doc') {
|
||||
$this->setHeaderDoc($file_name);
|
||||
}
|
||||
else if($type=='csv') {
|
||||
$this->setHeaderCSV($file_name);
|
||||
}
|
||||
|
||||
echo $content;
|
||||
}
|
||||
|
||||
// method for Excel file
|
||||
protected function setHeaderXLS($file_name)
|
||||
{
|
||||
header("Content-type: application/ms-excel");
|
||||
header("Content-Disposition: attachment; filename=$file_name");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
}
|
||||
|
||||
// method for Doc file
|
||||
protected function setHeaderDoc($file_name)
|
||||
{
|
||||
header("Content-type: application/x-ms-download");
|
||||
header("Content-Disposition: attachment; filename=$file_name");
|
||||
header('Cache-Control: public');
|
||||
}
|
||||
|
||||
// method for CSV file
|
||||
protected function setHeaderCSV($file_name)
|
||||
{
|
||||
header("Content-type: application/csv");
|
||||
header("Content-Disposition: inline; filename=$file_name");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user