PHPExcel PHP Class Code Examples

This page contains top rated real world PHP examples of class PHPExcel extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: PackageController.php Project: jimminababan/kontrol-anggaran
0
 public function actionExport()
 {
     $models = Package::model()->findAll();
     //code
     $objPHPExcel = new PHPExcel();
     /** Error reporting */
     error_reporting(E_ALL);
     ini_set('display_errors', TRUE);
     ini_set('display_startup_errors', TRUE);
     define('EOL', PHP_SAPI == 'cli' ? PHP_EOL : '<br />');
     date_default_timezone_set('Europe/London');
     /** PHPExcel_IOFactory */
     $objReader = new PHPExcel();
     $objReader = PHPExcel_IOFactory::createReader('Excel2007');
     $path = Yii::app()->basePath . '/../export/template.xlsx';
     $pathExport = Yii::app()->basePath . '/../export/daftar paket.xlsx';
     $objPHPExcel = $objReader->load($path);
     $objPHPExcel->setActiveSheetIndex(0);
     //       " Add new data to the template"
     $sheet = $objPHPExcel->getActiveSheet();
     $row = 5;
     $rowData1 = $row - 1;
     $rowData2 = $row - 1;
     $rowData3 = $row - 1;
     $rowData4 = $row - 1;
     $rowData5 = $row - 1;
     $sheet->insertNewRowBefore($row, count($models) - 1);
     for ($i = 1; $i <= count($models); $i++) {
         $sheet->setCellValue('A' . ($row - 2 + $i), $i);
     }
     foreach ($models as $model) {
         $sheet->setCellValue('B' . $rowData1++, "{$model->code}");
         $sheet->setCellValueExplicit('C' . $rowData2++, $model->ppk_code, PHPExcel_Cell_DataType::TYPE_STRING);
         $sheet->setCellValue('D' . $rowData3++, $model->limit);
         $sheet->setCellValue('E' . $rowData4++, $model->getTotal($model->code)["realization"]);
         $sheet->setCellValue('F' . $rowData5++, $model->getTotal($model->code)["restMoney"]);
     }
     $objPHPExcel->getActiveSheet()->setTitle('Daftar Paket');
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     $objWriter->save($pathExport);
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . basename($pathExport));
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate');
     header('Pragma: public');
     header('Content-Length: ' . filesize($pathExport));
     readfile($pathExport);
     unlink($pathExport);
     exit;
     //code
 }
Example #2
Show file File: CSV.php Project: hostellerie/nexpro
0
 /**
  * Loads PHPExcel from file into PHPExcel instance
  *
  * @param 	string 		$pFilename
  * @param	PHPExcel	$objPHPExcel
  * @throws 	Exception
  */
 public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
 {
     // Check if file exists
     if (!file_exists($pFilename)) {
         throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
     }
     // Create new PHPExcel
     while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
         $objPHPExcel->createSheet();
     }
     $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
     // Open file
     $fileHandle = fopen($pFilename, 'r');
     if ($fileHandle === false) {
         throw new Exception("Could not open file {$pFilename} for reading.");
     }
     // Loop trough file
     $currentRow = 0;
     $rowData = array();
     while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
         $currentRow++;
         for ($i = 0; $i < count($rowData); $i++) {
             if ($rowData[$i] != '') {
                 // Unescape enclosures
                 $rowData[$i] = str_replace("\\" . $this->_enclosure, $this->_enclosure, $rowData[$i]);
                 // Set cell value
                 $objPHPExcel->getActiveSheet()->setCellValue(PHPExcel_Cell::stringFromColumnIndex($i) . $currentRow, $rowData[$i]);
             }
         }
     }
     // Close file
     fclose($fileHandle);
     // Return
     return $objPHPExcel;
 }
Example #3
Show file File: HelperFunctions.php Project: Maxlander/shixi
0
 public static function makeXLSExportFile($exportData, $exportFileName, $title)
 {
     $excel = new PHPExcel();
     $excel->getActiveSheet()->setTitle($title);
     $row = 1;
     foreach ($exportData as $exportItem) {
         $col = 0;
         if ($row == 1) {
             foreach ($exportItem as $name => $value) {
                 $excel->getActiveSheet()->setCellValueByColumnAndRow($col, 1, $name);
                 $excel->getActiveSheet()->getStyleByColumnAndRow($col, 1)->applyFromArray(array('font' => array('bold' => true), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN))));
                 $col++;
             }
             $row = 2;
             $col = 0;
         }
         foreach ($exportItem as $fieldKey => $fieldVal) {
             if (strpos($fieldKey, '.ZipCode') !== false) {
                 $excel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $fieldVal, PHPExcel_Cell_DataType::TYPE_STRING);
             } else {
                 $excel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $fieldVal);
             }
             $excel->getActiveSheet()->getStyleByColumnAndRow($col, $row)->applyFromArray(array('borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN))));
             $col++;
         }
         $row++;
     }
     $export_files_dir = SJB_System::getSystemSettings('EXPORT_FILES_DIRECTORY');
     $objWriter = new PHPExcel_Writer_Excel5($excel);
     $objWriter->save($export_files_dir . '/' . $exportFileName);
 }
Example #4
Show file File: ImportSalesOrder.php Project: honj51/taobaocrm
0
 function createXls($accountinfs)
 {
     $headArr = array('合同订单编号', '状态', '客户名称', '联系人姓名', '签约日期', '合同金额', '产品名称', '产品编码', '数量', '价格', '备注');
     $filepath = $this->accountfile;
     if (is_array($accountinfs) && count($accountinfs) > 0) {
         $objPHPExcel = new PHPExcel();
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel5");
         $objWorksheet = $objPHPExcel->getActiveSheet();
         $rowIndex = 1;
         $cellIndex = 0;
         $headrows = $headArr;
         foreach ($headrows as $headcell) {
             $objWorksheet->getCellByColumnAndRow($cellIndex, $rowIndex)->setValue($headcell);
             $cellIndex += 1;
         }
         $rowIndex += 1;
         $cellIndex = 0;
         $accountrelation = array('subject', 'sostatus', 'account_id', 'contact_id', 'duedate', 'salestotal', 'productname', 'productcode', 'quantity', 'listprice', 'commet');
         foreach ($accountinfs as $accountinf) {
             foreach ($accountrelation as $pos => $propname) {
                 $accountval = $accountinf[$propname];
                 if ($propname == 'account_id') {
                     $accountval = getAccountName($accountval);
                 }
                 if ($propname == 'contact_id') {
                     $accountval = getContactName($accountval);
                 }
                 $objWorksheet->getCellByColumnAndRow($pos, $rowIndex)->setValueExplicit($accountval, PHPExcel_Cell_DataType::TYPE_STRING);
             }
             $rowIndex += 1;
         }
         $objWriter->save($filepath);
     }
 }
Example #5
Show file File: CommAction.class.php Project: ysking/commlib
0
 public function export()
 {
     vendor('PHPExcel.PHPExcel');
     $Excel = new PHPExcel();
     $Excel->getProperties()->setCreator("Marchsoft")->setLastModifiedBy("Marchsoft")->setTitle("Marchsoft")->setSubject("Marchsoft")->setDescription("Marchsoft")->setKeywords("Marchsoft")->setCategory("Marchsoft");
     $Excel->setActiveSheetIndex(0);
     $Sheet = $Excel->getActiveSheet();
     $ary = array("", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
     $Sheet->getDefaultColumnDimension()->setAutoSize(true);
     $Sheet->getDefaultStyle()->getFont()->setName('Arial');
     $Sheet->getDefaultStyle()->getFont()->setSize(13);
     $i = 1;
     $columns = C("columns." . MODULE_NAME);
     foreach ($columns as $key => $value) {
         $Sheet->setCellValue($ary[$i / 27] . $ary[$i % 27] . '1', $value);
         ++$i;
     }
     $M = D(MODULE_NAME);
     $result = $M->select();
     for ($j = 0; $j < count($result); ++$j) {
         $i = 1;
         foreach ($columns as $key => $value) {
             $Sheet->setCellValue($ary[$i / 27] . $ary[$i % 27] . ($j + 2), $result[$j][$key]);
             ++$i;
         }
     }
     date_default_timezone_set("Asia/Shanghai");
     $date = date("Y-m-d-H-i-s");
     header('Content-Type: application/vnd.ms-excel');
     header("Content-Disposition:attachment;filename = update_" . date('Y-m-d', mktime()) . ".xls");
     header("Pragma:no-cache");
     header("Expires:0");
     $objWriter = PHPExcel_IOFactory::createWriter($Excel, 'Excel5');
     $objWriter->save('php://output');
 }
Example #6
Show file File: ReportController.php Project: themesanasang/nth_supplier
0
 /**
  * รายงานมูลค่าคงคลังและมูลค่าการใช้
  */
 public function reportstoreall3($m, $y)
 {
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getDefaultStyle()->getFont()->setName('Arial');
     $objPHPExcel->getActiveSheet()->setTitle('Sheet1');
     $objPHPExcel->setActiveSheetIndex(0);
     $objPHPExcel->getActiveSheet()->setCellValue('A1', 'รายงานมูลค่าคงคลังและมูลค่าการใช้');
     $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(50);
     $objPHPExcel->getActiveSheet()->setCellValue('A2', 'รายการ');
     $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(50);
     $objPHPExcel->getActiveSheet()->setCellValue('B2', 'เดือน ' . $m . '/' . ($y + 543));
     $objPHPExcel->getActiveSheet()->getStyle('B')->getNumberFormat()->setFormatCode("#,##0.00");
     $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 4, 'มูลค่าคงคลัง');
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 5, 'มูลค่าการเบิก');
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 6, 'อัตราของคงคลัง');
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 4, $this->gettotaltype_A() + $this->gettotaltype_B() + $this->gettotaltype_C());
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 5, $this->gettotalissuemoney($m, $y));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 6, ($this->gettotaltype_A() + $this->gettotaltype_B() + $this->gettotaltype_C()) / $this->gettotalissuemoney($m, $y));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 7, $this->gettotaltype_A() + $this->gettotaltype_B() + $this->gettotaltype_C() - $this->gettotalissuemoney($m, $y));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 9, 'มูลค่าการใช้งาน');
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 10, 'สำนักงาน');
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 11, 'คอมพิวเตอร์');
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, 12, 'งานบ้าน-งานครัว');
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 10, $this->gettotalissuemoney_A($m, $y));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 11, $this->gettotalissuemoney_B($m, $y));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 12, $this->gettotalissuemoney_C($m, $y));
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(1, 13, $this->gettotalissuemoney_A($m, $y) + $this->gettotalissuemoney_B($m, $y) + $this->gettotalissuemoney_C($m, $y));
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     // Set excel version 2007
     $objWriter->save(storage_path() . "/report/reportstoreall3.xls");
     return Response::download(storage_path() . "/report/reportstoreall3.xls", "reportstoreall3.xls");
 }
Example #7
Show file File: Rels.php Project: ambagasdowa/kml
0
 /**
  * Write workbook relationships to XML format
  *
  * @param     PHPExcel    $pPHPExcel
  * @return     string         XML Output
  * @throws     PHPExcel_Writer_Exception
  */
 public function writeWorkbookRelationships(PHPExcel $pPHPExcel = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     // Relationship styles.xml
     $this->writeRelationship($objWriter, 1, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', 'styles.xml');
     // Relationship theme/theme1.xml
     $this->writeRelationship($objWriter, 2, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', 'theme/theme1.xml');
     // Relationship sharedStrings.xml
     $this->writeRelationship($objWriter, 3, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', 'sharedStrings.xml');
     // Relationships with sheets
     $sheetCount = $pPHPExcel->getSheetCount();
     for ($i = 0; $i < $sheetCount; ++$i) {
         $this->writeRelationship($objWriter, $i + 1 + 3, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', 'worksheets/sheet' . ($i + 1) . '.xml');
     }
     // Relationships for vbaProject if needed
     // id : just after the last sheet
     if ($pPHPExcel->hasMacros()) {
         $this->writeRelationShip($objWriter, $i + 1 + 3, 'http://schemas.microsoft.com/office/2006/relationships/vbaProject', 'vbaProject.bin');
         ++$i;
         //increment i if needed for an another relation
     }
     $objWriter->endElement();
     return $objWriter->getData();
 }
Example #8
Show file File: vendor.php Project: adamprasetia/acs
0
 function export()
 {
     $order_column = $this->input->get('order_column') != '' ? $this->input->get('order_column') : 'id';
     $order_type = $this->input->get('order_type') != '' ? $this->input->get('order_type') : 'asc';
     require_once "../assets/phpexcel/PHPExcel.php";
     $excel = new PHPExcel();
     $excel->setActiveSheetIndex(0);
     $active_sheet = $excel->getActiveSheet();
     $active_sheet->setTitle('Vendor List');
     //style
     $active_sheet->getStyle("A1:D1")->getFont()->setBold(true);
     //header
     $active_sheet->setCellValue('A1', 'No');
     $active_sheet->setCellValue('B1', 'Vendor Name');
     $active_sheet->setCellValue('C1', 'Address');
     $active_sheet->setCellValue('D1', 'Telephone');
     $result = $this->mdl_vendor->export($order_column, $order_type)->result();
     $i = 2;
     foreach ($result as $r) {
         $active_sheet->setCellValue('A' . $i, $i - 1);
         $active_sheet->setCellValue('B' . $i, $r->name);
         $active_sheet->setCellValue('C' . $i, $r->address);
         $active_sheet->setCellValue('D' . $i, $r->tlp);
         $i++;
     }
     $filename = 'LIST_VENDOR_' . date('Ymd_His') . '.xlsx';
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="' . $filename . '"');
     header('Cache-Control: max-age=0');
     $objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
     $objWriter->save('php://output');
 }
Example #9
Show file File: RelsVBA.php Project: ljhchshm/weixin
0
 /**
  * Write relationships for a signed VBA Project
  *
  * @param 	PHPExcel	$pPHPExcel
  * @return 	string 		XML Output
  * @throws 	PHPExcel_Writer_Exception
  */
 public function writeVBARelationships(PHPExcel $pPHPExcel = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     $objWriter->startElement('Relationship');
     $objWriter->writeAttribute('Id', 'rId1');
     $objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature');
     $objWriter->writeAttribute('Target', 'vbaProjectSignature.bin');
     $objWriter->endElement();
     //Relationship
     $objWriter->endElement();
     //Relationships
     // Return
     return $objWriter->getData();
 }
Example #10
Show file File: Serialized.php Project: kumarsivarajan/ctrl-dock
0
 /**
  * Serialize PHPExcel object to XML
  *
  * @param 	PHPExcel	$pPHPExcel
  * @param 	string		$pFilename
  * @return 	string 		XML Output
  * @throws 	Exception
  */
 private function _writeSerialized(PHPExcel $pPHPExcel = null, $pFilename = '')
 {
     // Clone $pPHPExcel
     $pPHPExcel = clone $pPHPExcel;
     // Update media links
     $sheetCount = $pPHPExcel->getSheetCount();
     for ($i = 0; $i < $sheetCount; ++$i) {
         for ($j = 0; $j < $pPHPExcel->getSheet($i)->getDrawingCollection()->count(); ++$j) {
             if ($pPHPExcel->getSheet($i)->getDrawingCollection()->offsetGet($j) instanceof PHPExcel_Worksheet_BaseDrawing) {
                 $imgTemp =& $pPHPExcel->getSheet($i)->getDrawingCollection()->offsetGet($j);
                 $imgTemp->setPath('zip://' . $pFilename . '#media/' . $imgTemp->getFilename(), false);
             }
         }
     }
     // Create XML writer
     $objWriter = new xmlWriter();
     $objWriter->openMemory();
     $objWriter->setIndent(true);
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // PHPExcel
     $objWriter->startElement('PHPExcel');
     $objWriter->writeAttribute('version', '1.7.3');
     // Comment
     $objWriter->writeComment('This file has been generated using PHPExcel v1.7.3 (http://www.codeplex.com/PHPExcel). It contains a base64 encoded serialized version of the PHPExcel internal object.');
     // Data
     $objWriter->startElement('data');
     $objWriter->writeCData(base64_encode(serialize($pPHPExcel)));
     $objWriter->endElement();
     $objWriter->endElement();
     // Return
     return $objWriter->outputMemory(true);
 }
Example #11
Show file File: RelsRibbon.php Project: AlexandreSGV/siteentec
0
 /**
  * Write relationships for additional objects of custom UI (ribbon)
  *
  * @param 	PHPExcel	$pPHPExcel
  * @return 	string 		XML Output
  * @throws 	PHPExcel_Writer_Exception
  */
 public function writeRibbonRelationships(PHPExcel $pPHPExcel = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     $localRels = $pPHPExcel->getRibbonBinObjects('names');
     if (is_array($localRels)) {
         foreach ($localRels as $aId => $aTarget) {
             $objWriter->startElement('Relationship');
             $objWriter->writeAttribute('Id', $aId);
             $objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
             $objWriter->writeAttribute('Target', $aTarget);
             $objWriter->endElement();
             //Relationship
         }
     }
     $objWriter->endElement();
     //Relationships
     // Return
     return $objWriter->getData();
 }
Example #12
Show file File: Workbook.php Project: ljhchshm/weixin
0
 /**
  * Class constructor
  *
  * @param PHPExcel	$phpExcel		The Workbook
  * @param int		&$str_total		Total number of strings
  * @param int		&$str_unique	Total number of unique strings
  * @param array		&$str_table		String Table
  * @param array		&$colors		Colour Table
  * @param mixed		$parser			The formula parser created for the Workbook
  */
 public function __construct(PHPExcel $phpExcel = null, &$str_total, &$str_unique, &$str_table, &$colors, $parser)
 {
     // It needs to call its parent's constructor explicitly
     parent::__construct();
     $this->_parser = $parser;
     $this->_biffsize = 0;
     $this->_palette = array();
     $this->_country_code = -1;
     $this->_str_total =& $str_total;
     $this->_str_unique =& $str_unique;
     $this->_str_table =& $str_table;
     $this->_colors =& $colors;
     $this->_setPaletteXl97();
     $this->_phpExcel = $phpExcel;
     // set BIFFwriter limit for CONTINUE records
     //		$this->_limit = 8224;
     $this->_codepage = 0x4b0;
     // Add empty sheets and Build color cache
     $countSheets = $phpExcel->getSheetCount();
     for ($i = 0; $i < $countSheets; ++$i) {
         $phpSheet = $phpExcel->getSheet($i);
         $this->_parser->setExtSheet($phpSheet->getTitle(), $i);
         // Register worksheet name with parser
         $supbook_index = 0x0;
         $ref = pack('vvv', $supbook_index, $i, $i);
         $this->_parser->_references[] = $ref;
         // Register reference with parser
         // Sheet tab colors?
         if ($phpSheet->isTabColorSet()) {
             $this->_addColor($phpSheet->getTabColor()->getRGB());
         }
     }
 }
Example #13
Show file File: rbacRouter.class.php Project: w3hacker/queryphp
0
 public function exportdaili()
 {
     $p = M("r.project");
     $p->getAll("desc");
     $projectlist = $p->getRecord();
     $pre = array("1" => "北京市", "2" => "天津市", "3" => "上海市", "4" => "重庆市", "5" => "河北省", "6" => "河南省", "7" => "山东省", "8" => "山西省", "9" => "广东省", "10" => "甘肃省", "11" => "陕西省", "12" => "浙江省", "13" => "江苏省", "14" => "安徽省", "15" => "湖南省", "16" => "湖北省", "17" => "四川省", "18" => "辽宁省", "19" => "吉林省", "20" => "江西省", "21" => "云南省", "22" => "贵州省", "23" => "福建省", "24" => "青海省", "25" => "黑龙江省", "26" => "广西自治区", "27" => "西藏自治区", "28" => "新疆自治区", "29" => "宁夏自治区", "30" => "内蒙古自治区", "31" => "大陆以外地区");
     date_default_timezone_set('Asia/Shanghai');
     import('@plugin.Classes.PHPExcel');
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 XLSX Test Document")->setSubject("Office 2007 XLSX Test Document")->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory(" php to result file");
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', '机构名称')->setCellValue('B1', '省份')->setCellValue('C1', '联系人')->setCellValue('D1', '职务')->setCellValue('E1', '电话')->setCellValue('F1', '手机')->setCellValue('G1', '电子邮件')->setCellValue('H1', '地址')->setCellValue('I1', '帐号');
     $i = 2;
     foreach ($projectlist as $k => $v) {
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $i, $v['projectname'])->setCellValue('B' . $i, $pre[$v['province']])->setCellValue('C' . $i, $v['linkname'])->setCellValue('D' . $i, $v['job_bm'])->setCellValue('E' . $i, $v['iphone1'] . "-" . $v['iphone2'] . "-" . $v['iphone3'])->setCellValue('F' . $i, $v['mobile'])->setCellValue('G' . $i, $v['email'])->setCellValue('H' . $i, $v['regaddress'])->setCellValue('I' . $i, $v['loginname']);
         $i++;
     }
     $objPHPExcel->getActiveSheet()->setTitle('代理数据备份');
     $objPHPExcel->setActiveSheetIndex(0);
     $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     ob_end_clean();
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="daili' . date("Y_m_d") . '.xls"');
     header('Cache-Control: max-age=0');
     $objWriter->save('php://output');
     exit;
 }
Example #14
Show file File: HTML.php Project: agashish/test_new
0
 /**
  * Loads PHPExcel from file into PHPExcel instance
  *
  * @param 	string 		$pFilename
  * @param	PHPExcel	$objPHPExcel
  * @return 	PHPExcel
  * @throws 	PHPExcel_Reader_Exception
  */
 public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
 {
     // Open file to validate
     $this->_openFile($pFilename);
     if (!$this->_isValidFormat()) {
         fclose($this->_fileHandle);
         throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
     }
     //	Close after validating
     fclose($this->_fileHandle);
     // Create new PHPExcel
     while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
         $objPHPExcel->createSheet();
     }
     $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
     //	Create a new DOM object
     $dom = new domDocument();
     //	Reload the HTML file into the DOM object
     $loaded = $dom->loadHTMLFile($pFilename);
     if ($loaded === FALSE) {
         throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
     }
     //	Discard white space
     $dom->preserveWhiteSpace = false;
     $row = 0;
     $column = 'A';
     $content = '';
     $this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
     //		echo '<hr />';
     //		var_dump($this->_dataArray);
     // Return
     return $objPHPExcel;
 }
Example #15
Show file File: old_CronjobsController.php Project: agashish/test_new
0
 public function ukAmazonFees()
 {
     $this->layout = '';
     $this->autoRender = false;
     $this->loadModel('AmazonFee');
     $this->loadModel('Location');
     App::import('Vendor', 'PHPExcel/IOFactory');
     $objPHPExcel = new PHPExcel();
     $objReader = PHPExcel_IOFactory::createReader('CSV');
     $objReader->setReadDataOnly(true);
     $objPHPExcel = $objReader->load('files/uk_amazon_fees.csv');
     $objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
     $lastRow = $objPHPExcel->getActiveSheet()->getHighestRow();
     $colString = $highestColumn = $objPHPExcel->getActiveSheet()->getHighestColumn();
     $colNumber = PHPExcel_Cell::columnIndexFromString($colString);
     for ($i = 2; $i <= $lastRow; $i++) {
         $this->request->data['category'] = $objWorksheet->getCellByColumnAndRow(0, $i)->getValue();
         $this->request->data['referral_fee'] = $objWorksheet->getCellByColumnAndRow(1, $i)->getValue();
         $this->request->data['app_min_referral_fee'] = $objWorksheet->getCellByColumnAndRow(2, $i)->getValue();
         $country = $this->Location->find('first', array('conditions' => array('Location.county_name' => $objWorksheet->getCellByColumnAndRow(3, $i)->getValue())));
         $this->request->data['country'] = $country['Location']['id'];
         $this->request->data['platform'] = $objWorksheet->getCellByColumnAndRow(4, $i)->getValue();
         $this->AmazonFee->create();
         $this->AmazonFee->save($this->request->data);
     }
 }
Example #16
Show file File: Rels.php Project: portokallidis/Metamorphosis-Meducator
0
 /**
  * Write workbook relationships to XML format
  *
  * @param 	PHPExcel	$pPHPExcel
  * @return 	string 		XML Output
  * @throws 	Exception
  */
 public function writeWorkbookRelationships(PHPExcel $pPHPExcel = null)
 {
     // Create XML writer
     $objWriter = null;
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // Relationships
     $objWriter->startElement('Relationships');
     $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
     // Relationship styles.xml
     $this->_writeRelationship($objWriter, 1, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', 'styles.xml');
     // Relationship theme/theme1.xml
     $this->_writeRelationship($objWriter, 2, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', 'theme/theme1.xml');
     // Relationship sharedStrings.xml
     $this->_writeRelationship($objWriter, 3, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings', 'sharedStrings.xml');
     // Relationships with sheets
     $sheetCount = $pPHPExcel->getSheetCount();
     for ($i = 0; $i < $sheetCount; ++$i) {
         $this->_writeRelationship($objWriter, $i + 1 + 3, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet', 'worksheets/sheet' . ($i + 1) . '.xml');
     }
     $objWriter->endElement();
     // Return
     return $objWriter->getData();
 }