Pages

Showing posts with label PHPExcel library. Show all posts
Showing posts with label PHPExcel library. Show all posts

8 Mar 2016

Freeing Disk Space on C:\ Windows Server 2008

Freeing Disk Space on C:\ Windows Server 2008


I just spent the last little while trying to clear space on our servers in order to install .NET 4.5. Decided to post so my future self can find the information when I next have to do this.
I performed all the usual tasks:

  • Deleting any files/folders from C:\windows\temp and C:\Users\%UserName%\AppData\Local\Temp
  • Delete all EventViewer logs
    • Save to another Disk if you want to keep them
  • Remove any unused programs, e.g. Firefox
  • Remove anything in C:\inetpub\logs
  • Remove any file/folders C:\Windows\System32\LogFiles
  • Remove any file/folders from C:\Users\%UserName%\Downloads
  • Remove any file/folders able to be removed from C:\Users\%UserName%\Desktop
  • Remove any file/folders able to be removed from C:\Users\%UserName%\My Documents
  • Stop Windows Update service and remove all files/folders from C:\Windows\SoftwareDistribution
  • Deleting an Event Logs
  • Run COMPCLN.exe
  • Move the Virtual Memory file to another disk

12 Feb 2016

My SQL Database table record export to excel and send mail with attachmnet -Using PHP Codeigniter Framework


Send mail with attachmnet - PHP Codeigniter Framework

function export()
    {
$this->load->helper('date');
$params= $this->input->post('params');
        $query = $this->db->query("select * from tbl_order where orderid in ($params)");

        if(!$query)
            return false;
        // Starting the PHPExcel library
        $this->load->library('PHPExcel');
        //$this->load->library('PHPExcel/IOFactory/PHPExcel_IOFactory');
        $objPHPExcel = new PHPExcel();
        $objPHPExcel->getProperties()->setTitle("export")->setDescription("none");
        $objPHPExcel->setActiveSheetIndex(0);
        // Field names in the first row
        $fields = $query->list_fields();
        $col = 0;
        foreach ($fields as $field)
        {
            $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $field);
            $col++;
        }
        // Fetching the table data
        $row = 2;
        foreach($query->result() as $data)
        {
            $col = 0;
            foreach ($fields as $field)
            {
                $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $data->$field);
                $col++;
            }

            $row++;
        }
        $objPHPExcel->setActiveSheetIndex(0);

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$filepath=site_url('css/'.date('dMy').'.xls');
$dateposted = date("Ymdhis");   
$objWriter->save(str_replace(__FILE__, $dateposted.'.xls', __FILE__));
echo "<script>alert('File saved at drive C')</script>";

//Send mail attachment
$this->load->library('email'); // load email library
$this->email->from('info@domainname.com', 'Subject');
$this->email->to('toemmail@domain.com');
$this->email->cc('ccemail@domian.com'); 
$this->email->subject('Subject');
$this->email->attach($dateposted.'.xls');
$this->email->send();
 
    }