Created
June 25, 2016 07:48
-
-
Save goelvibhor4/abb9b100599aa509fc11f7e6146e2682 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$query0 = "select name,estimate_number from campaigns_hul where id = '$cid'"; | |
$data0 = $this->db->query($query0)->result(); | |
//print_r($data0); die(); | |
$query = "select pp.photo,s.city,s.locality,s.start_date,s.end_date,s.size,s.lighting,s.media_type " | |
. "FROM tasks_hul t " | |
. "LEFT JOIN campaigns_hul c ON c.id = t.campaign_id " | |
. "LEFT JOIN sites_hul s ON s.site_id = t.site_id " | |
. "LEFT JOIN photoproof_hul pp ON pp.task_id = t.task_id " | |
. "LEFT JOIN vendors_hul v ON v.vendor_id = t.vendor_id " | |
. "WHERE t.campaign_id = '$cid' and pp.photo != '' " | |
. "GROUP BY t.task_id order by t.t_date desc "; | |
$data = $this->db->query($query)->result(); | |
//print_r($data); die(); | |
error_reporting(E_ALL); | |
ini_set('include_path', ini_get('include_path').';../Classes/'); | |
include 'application/controllers/excelLib/PHPExcel.php'; | |
include 'application/controllers/excelLib/PHPExcel/Writer/Excel2007.php'; | |
$excel = new PHPExcel(); | |
$excel = PHPExcel_IOFactory::load('application/controllers/excelLib/template.xlsx'); | |
header('Content-Type: application/vnd.ms-excel'); | |
header('Content-Disposition: attachment;filename="your_name.xls"'); | |
header('Cache-Control: max-age=0'); | |
$objDrawing = new PHPExcel_Worksheet_Drawing(); | |
$objDrawing->setName('Logo'); | |
$objDrawing->setDescription('Logo'); | |
$logo = 'application/controllers/excelLib/logo.png';// Provide path to | |
$objDrawing->setPath($logo); //setOffsetY has no effect | |
$objDrawing->setCoordinates('A1'); | |
$objDrawing->setHeight(100); | |
$objDrawing->setWorksheet($excel->getActiveSheet()); | |
$testArray = array( | |
array ('Invoice no',':'), | |
array('Invoice Date',':'), | |
array('Brand Name',':'), | |
array('Estimate no',':'), | |
array('Campaign',':') | |
); | |
foreach($data0 as $d0) { | |
$testArray2 = array( | |
array (''), | |
array(''), | |
array($d0->name), | |
array($d0->estimate_number), | |
array($d0->name) | |
); | |
} | |
$row = 7; | |
$s_no = 1; | |
$row2 = 25; | |
foreach($data as $d) { | |
$objDrawing2 = new PHPExcel_Worksheet_Drawing(); | |
$objDrawing2->setName('PHPExcel logo'); | |
$objDrawing2->setDescription('PHPExcel logo'); | |
$objDrawing2->setPath('assets/img/listing/'.$d->photo); | |
$objDrawing2->setHeight(200); | |
$objDrawing2->setWidth(600); | |
$objDrawing2->setCoordinates('A'.$row); | |
$objDrawing2->setOffsetX(10); | |
$objDrawing2->setWorksheet($excel->getActiveSheet()); | |
$testArray3 = array( | |
array ('Sr no',':',$s_no), | |
array('City',':',$d->city), | |
array('Location',':',$d->locality), | |
array('Period',':',$d->start_date."To ".$d->end_date), | |
); | |
$testArray4 = array( | |
array ('Sr No in EST',':',$s_no), | |
array('Size',':',$d->size), | |
array('Vehicle',':',$d->media_type), | |
array('Type',':',$d->lighting), | |
); | |
$excel->getActiveSheet()->fromArray($testArray3, NULL, 'A'.$row2); | |
$excel->getActiveSheet()->fromArray($testArray4, NULL, 'H'.$row2); | |
$row = $row + 23; | |
$s_no = $s_no + 1; | |
$row2 = $row2 + 23; | |
} | |
// logo height | |
$excel->getActiveSheet()->fromArray($testArray, NULL, 'G1'); | |
$excel->getActiveSheet()->fromArray($testArray2, NULL, 'I1'); | |
$writer = PHPExcel_IOFactory::createWriter($excel, 'Excel5'); | |
$writer->save("excel.xls"); | |
readfile("excel.xls"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment