This commit is contained in:
2025-10-04 11:46:59 +07:00
commit 97427d7cff
498 changed files with 47596 additions and 0 deletions

View 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");
}
}