当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel::disconnectWorksheets方法代码示例

本文整理汇总了PHP中PHPExcel::disconnectWorksheets方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel::disconnectWorksheets方法的具体用法?PHP PHPExcel::disconnectWorksheets怎么用?PHP PHPExcel::disconnectWorksheets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel的用法示例。


在下文中一共展示了PHPExcel::disconnectWorksheets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mockWorkbook

 /**
  * @return \PHPExcel
  */
 protected function mockWorkbook()
 {
     $workbook = new \PHPExcel();
     $workbook->disconnectWorksheets();
     $workbook->getProperties()->setTitle('mocked');
     $sheet = new \PHPExcel_Worksheet($workbook);
     $sheet->fromArray([['test', 'test', 'test'], ['test', 'test', 'test'], ['test', 'test', 'test'], ['test', 'test', 'test']]);
     $workbook->addSheet($sheet);
     $sheet = new \PHPExcel_Worksheet($workbook);
     $sheet->fromArray([['test', 'test', 'test'], ['test', 'test', 'test'], ['test', 'test', 'test'], ['test', 'test', 'test']]);
     $workbook->addSheet($sheet);
     $workbook->setActiveSheetIndex(0);
     return $workbook;
 }
开发者ID:ymnl007,项目名称:Clerk,代码行数:17,代码来源:WorkbookParserTest.php

示例2: mockRow

 /**
  * @return \PHPExcel
  */
 protected function mockRow()
 {
     $workbook = new \PHPExcel();
     $workbook->disconnectWorksheets();
     $sheet = new \PHPExcel_Worksheet($workbook);
     $sheet->fromArray([['a1', 'b1', 'c1']]);
     $row = new \PHPExcel_Worksheet_Row($sheet, 1);
     return $row;
 }
开发者ID:ymnl007,项目名称:Clerk,代码行数:12,代码来源:RowParserTest.php

示例3: mockSheet

 /**
  * @return \PHPExcel_Worksheet
  */
 protected function mockSheet()
 {
     $workbook = new \PHPExcel();
     $workbook->disconnectWorksheets();
     $sheet = new \PHPExcel_Worksheet($workbook);
     $sheet->setTitle('mocked');
     $sheet->fromArray([['a1', 'b1'], ['a2', 'b2']]);
     return $sheet;
 }
开发者ID:ymnl007,项目名称:Clerk,代码行数:12,代码来源:SheetParserTest.php

示例4: mockCell

 /**
  * @param string $text
  *
  * @return Cell
  */
 protected function mockCell($text = 'text', $settings = false)
 {
     $workbook = new \PHPExcel();
     $workbook->disconnectWorksheets();
     $worksheet = new \PHPExcel_Worksheet($workbook);
     $workbook->addSheet($worksheet);
     $cell = $worksheet->setCellValue('A1', $pValue = $text, $returnCell = true);
     $settings = $settings ?: new ParserSettings();
     $cell = new Cell($cell, 1, $settings);
     return $cell;
 }
开发者ID:ymnl007,项目名称:Clerk,代码行数:16,代码来源:CellTest.php

示例5: saveFile

 /**
  * Save file to disk.
  *
  * By default, it will not overwrite an existing file with the same name.
  *
  * @param string $filename Filename with path
  * @param string $format A value from \PHPExcel_IOFactory::$_autoResolveClasses
  * @param bool $canOverWrite Set to true if you want to let an existing file be overwritten upon saving.
  *
  * @return bool
  * @throws FileExistsException
  * @throws \PHPExcel_Reader_Exception
  */
 public function saveFile($filename, $format, $canOverWrite = false)
 {
     $objWriter = \PHPExcel_IOFactory::createWriter($this->objPHPExcel, $format);
     if (!$canOverWrite and file_exists($filename)) {
         throw new FileExistsException();
     }
     $objWriter->save($filename);
     $this->objPHPExcel->disconnectWorksheets();
     unset($this->objPHPExcel);
     return true;
 }
开发者ID:ChMat,项目名称:ExcelBundle,代码行数:24,代码来源:ExcelWriter.php

示例6: writeFile

 /**
  * Create excel file and store in tmp dir
  *
  * @param string $filename
  * @param string $format
  * @param bool   $disconnect
  * @return string
  */
 private function writeFile($filename, $format = 'Excel2007', $disconnect = true)
 {
     $path = sprintf('%s/%s', $this->path, $filename);
     $objWriter = \PHPExcel_IOFactory::createWriter($this->file, $format);
     $objWriter->save($path);
     if ($disconnect) {
         $this->file->disconnectWorksheets();
         unset($this->file);
     }
     $this->fileName = $filename;
     $this->filePath = $path;
     return $path;
 }
开发者ID:prezent,项目名称:translation-bundle,代码行数:21,代码来源:Exporter.php

示例7: __destruct

 public function __destruct()
 {
     $this->_xls->disconnectWorksheets();
     unset($this->_xls);
 }
开发者ID:justus-alex,项目名称:TaxiPrize,代码行数:5,代码来源:ExcelSource.php

示例8: create_excel

 public function create_excel($excel_data = NUll)
 {
     //check if the excel data has been set if not exit the excel generation
     if (count($excel_data) > 0) {
         $objPHPExcel = new PHPExcel();
         $objPHPExcel->getProperties()->setCreator("HCMP");
         $objPHPExcel->getProperties()->setLastModifiedBy($excel_data['doc_creator']);
         $objPHPExcel->getProperties()->setTitle($excel_data['doc_title']);
         $objPHPExcel->getProperties()->setSubject($excel_data['doc_title']);
         $objPHPExcel->getProperties()->setDescription("");
         $objPHPExcel->setActiveSheetIndex(0);
         $rowExec = 1;
         //Looping through the cells
         $column = 0;
         foreach ($excel_data['column_data'] as $column_data) {
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column, $rowExec, $column_data);
             $objPHPExcel->getActiveSheet()->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($column))->setAutoSize(true);
             //$objPHPExcel->getActiveSheet()->getStyle($column, $rowExec)->getFont()->setBold(true);
             $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow($column, $rowExec)->getFont()->setBold(true);
             $column++;
         }
         $rowExec = 2;
         foreach ($excel_data['row_data'] as $row_data) {
             $column = 0;
             foreach ($row_data as $cell) {
                 //Looping through the cells per facility
                 $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column, $rowExec, $cell);
                 $column++;
             }
             $rowExec++;
         }
         $objPHPExcel->getActiveSheet()->setTitle('Simple');
         // Save Excel 2007 file
         //echo date('H:i:s') . " Write to Excel2007 format\n";
         $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
         // We'll be outputting an excel file
         header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
         header("Cache-Control: no-store, no-cache, must-revalidate");
         header("Cache-Control: post-check=0, pre-check=0", false);
         header("Pragma: no-cache");
         // It will be called file.xls
         header("Content-Disposition: attachment; filename=" . $excel_data['file_name'] . ".xlsx");
         // Write file to the browser
         $objWriter->save('php://output');
         $objPHPExcel->disconnectWorksheets();
         unset($objPHPExcel);
         // Echo done
     }
 }
开发者ID:HCMPKenya,项目名称:RTK_TEST,代码行数:49,代码来源:sms.php

示例9: generate_excel

 private function generate_excel($records = 'all')
 {
     require_once APPPATH . 'third_party/phpexcel/Classes/PHPExcel.php';
     require_once APPPATH . 'third_party/phpexcel/Classes/PHPExcel/Writer/Excel2007.php';
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->getProperties()->setCreator("MDB Order Management System");
     $objPHPExcel->getProperties()->setLastModifiedBy("MDB Order Management System");
     $objPHPExcel->getProperties()->setTitle("Order Exportation on 03-12-2014");
     $objPHPExcel->getProperties()->setSubject("Order Exportation on 03-12-2014");
     $objPHPExcel->getProperties()->setDescription("Order Exportation on 03-12-2014");
     $objPHPExcel->setActiveSheetIndex(0);
     $objPHPExcel->setActiveSheetIndex(0);
     // Column Header Setting
     $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Customer No.');
     $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Code');
     $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Name');
     $objPHPExcel->getActiveSheet()->SetCellValue('D1', 'Address');
     $objPHPExcel->getActiveSheet()->SetCellValue('E1', 'Address 2');
     $objPHPExcel->getActiveSheet()->SetCellValue('F1', 'City');
     $objPHPExcel->getActiveSheet()->SetCellValue('G1', 'State');
     $objPHPExcel->getActiveSheet()->SetCellValue('H1', 'Zip');
     $objPHPExcel->getActiveSheet()->SetCellValue('I1', 'Country/Region Code');
     $objPHPExcel->getActiveSheet()->SetCellValue('J1', 'Contact Name');
     $objPHPExcel->getActiveSheet()->SetCellValue('K1', 'Phone No.');
     $objPHPExcel->getActiveSheet()->SetCellValue('L1', 'Ship To Location');
     $objPHPExcel->getActiveSheet()->SetCellValue('M1', 'Store Location');
     $objPHPExcel->getActiveSheet()->SetCellValue('N1', 'Email');
     $row = 2;
     if ($records == 'all') {
         $records = $this->portal_model->get_all_records_for_export();
     }
     foreach ($records as $record) {
         $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, htmlspecialchars_decode($record['CustNo'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $record['Code']);
         $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, htmlspecialchars_decode($record['Name'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, htmlspecialchars_decode($record['Address'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, htmlspecialchars_decode($record['Address2'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, htmlspecialchars_decode($record['City'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, htmlspecialchars_decode($record['State'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, htmlspecialchars_decode($record['Zip'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, htmlspecialchars_decode($record['Country'], ENT_QUOTES));
         //$objPHPExcel->getActiveSheet()->SetCellValue('J'.$row, $record['Contact']);
         $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, htmlspecialchars_decode($record['Phone'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, htmlspecialchars_decode($record['isShipTo'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, htmlspecialchars_decode($record['isStore'], ENT_QUOTES));
         $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, htmlspecialchars_decode($record['Email'], ENT_QUOTES));
         $row++;
     }
     $datestring = date('YmdHisu');
     $objPHPExcel->getActiveSheet()->setTitle('Simple');
     $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
     $objWriter->save('application/files/retailer-survey-' . $datestring . '.xlsx');
     //$objWriter->save(APPPATH . 'third_party/orders-' . date('YmdHisu') . '.csv');
     $objPHPExcel->disconnectWorksheets();
     unset($objPHPExcel);
     header('Pragma: public');
     header('Pragma: no-cache');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Description: File Transfer');
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8;');
     header('Content-Length: ' . filesize(APPPATH . 'third_party/orders-' . $datestring . '.xlsx'));
     header("Content-Disposition: attachment;filename=transaction-export-" . date('Y-m-d') . ".xlsx");
     header('Content-Transfer-Encoding: binary');
     ob_clean();
     flush();
     if (@readfile('application/files/retailer-survey-' . $datestring . '.xlsx')) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:mdbhk,项目名称:retailersurvey.themdbfamily.com,代码行数:72,代码来源:portal.php

示例10: patient_consumption

 public function patient_consumption($period_start = "", $period_end = "")
 {
     $patients = array();
     $oi_drugs = array();
     //get all regimen drugs from OI
     $sql = "SELECT IF(d.drug IS NULL,rd.drugcode,d.drug) as drugname,'' as drugqty\n              FROM regimen_drug rd \n              LEFT JOIN regimen r ON r.id=rd.regimen\n              LEFT JOIN regimen_service_type rst ON rst.id=r.type_of_service\n              LEFT JOIN drugcode d ON d.id=rd.drugcode\n              WHERE rst.name LIKE '%oi%'\n              AND d.drug NOT LIKE '%cot%'\n              GROUP BY drugname";
     $query = $this->db->query($sql);
     $drugs = $query->result_array();
     if ($drugs) {
         foreach ($drugs as $drug) {
             $oi_drugs[$drug['drugname']] = $drug['drugqty'];
         }
     }
     //get all patients dispensed,drug and in this period
     $sql = "SELECT pv.patient_id,CONCAT_WS( '/', MONTH( pv.dispensing_date ) , YEAR( pv.dispensing_date ) ) AS Month_Year, group_concat(d.drug) AS ARVDrug, group_concat(pv.quantity) AS ARVQTY\n\t\t\t  FROM v_patient_visits pv \n\t\t\t  LEFT JOIN drugcode d ON d.id = pv.drug_id\n\t\t\t  WHERE pv.dispensing_date\n\t\t\t  BETWEEN '" . $period_start . "'\n\t\t\t  AND '" . $period_end . "'\n\t\t\t  GROUP BY pv.patient_id, CONCAT_WS( '/', MONTH( pv.dispensing_date ) , YEAR( pv.dispensing_date ) )\n\t\t\t  ORDER BY pv.patient_id";
     $query = $this->db->query($sql);
     $transactions = $query->result_array();
     if ($transactions) {
         foreach ($transactions as $transaction) {
             $oi = $oi_drugs;
             $is_oi = FALSE;
             //split comma seperated drugs to array
             $drugs = $transaction['ARVDrug'];
             $drugs = explode(",", $drugs);
             //split comma seperated qtys to array
             $qtys = $transaction['ARVQTY'];
             $qtys = explode(",", $qtys);
             foreach ($drugs as $index => $drug) {
                 //add drug qtys to oi
                 if (array_key_exists($drug, $oi)) {
                     $is_oi = TRUE;
                     $oi[$drug] = $qtys[$index];
                 }
             }
             //add drug consumption to patient
             if ($is_oi == TRUE) {
                 $patients[$transaction['patient_id']] = $oi;
             }
         }
     }
     //export patient transactions
     $this->load->library('PHPExcel');
     $dir = "Export";
     $objPHPExcel = new PHPExcel();
     $objPHPExcel->setActiveSheetIndex(0);
     /*Delete all files in export folder*/
     if (is_dir($dir)) {
         $files = scandir($dir);
         foreach ($files as $object) {
             if ($object != "." && $object != "..") {
                 unlink($dir . "/" . $object);
             }
         }
     } else {
         mkdir($dir);
     }
     //get columns
     $column = array();
     $letter = 'A';
     while ($letter !== 'AAA') {
         $column[] = $letter++;
     }
     //set col and row indices
     $col = 0;
     $row = 1;
     //wrap header text
     $objPHPExcel->getActiveSheet()->getStyle('A1:A' . $objPHPExcel->getActiveSheet()->getHighestRow())->getAlignment()->setWrapText(true);
     //autosize header
     $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(-1);
     //print
     $objPHPExcel->getActiveSheet()->SetCellValue($column[$col] . $row, "ARTID");
     $col++;
     $objPHPExcel->getActiveSheet()->SetCellValue($column[$col] . $row, "PERIOD");
     foreach ($oi_drugs as $drugname => $header) {
         $col++;
         $objPHPExcel->getActiveSheet()->SetCellValue($column[$col] . $row, $drugname);
     }
     //loop through patient transactions
     foreach ($patients as $art_id => $dispenses) {
         //reset col and row indices
         $col = 0;
         $row++;
         //write art_id and period reporting
         $objPHPExcel->getActiveSheet()->SetCellValue($column[$col] . $row, $art_id);
         $col++;
         $objPHPExcel->getActiveSheet()->SetCellValue($column[$col] . $row, date("m/Y", strtotime($period_start)));
         foreach ($dispenses as $drug_id => $drug_qty) {
             $col++;
             $objPHPExcel->getActiveSheet()->SetCellValue($column[$col] . $row, $drug_qty);
         }
     }
     //Generate file
     ob_start();
     $period_start = date("F-Y", strtotime($period_start));
     $original_filename = "PATIENT DRUG CONSUMPTION[" . $period_start . "].xls";
     $filename = $dir . "/" . urldecode($original_filename);
     $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
     $objWriter->save($filename);
     $objPHPExcel->disconnectWorksheets();
     unset($objPHPExcel);
//.........这里部分代码省略.........
开发者ID:OmondiKevin,项目名称:ADT_MTRH,代码行数:101,代码来源:report_management.php

示例11: freeMemory

 /**
  * Free memory
  *
  * @return void
  */
 public function freeMemory()
 {
     $this->_xls->disconnectWorksheets();
     unset($this->_xls);
 }
开发者ID:julianpollmann,项目名称:PhpExcel,代码行数:10,代码来源:PhpExcelComponent.php

示例12: fn_price_list_is_xls_supported

        $params = $_REQUEST;
        $params['sort_by'] = $price_schema['fields'][Registry::get('addons.price_list.price_list_sorting')]['sort_by'];
        $params['page'] = $page;
        $params['skip_view'] = 'Y';
        fn_price_list_print_products($params, $worksheet, $counter, $row, $width, $selected_fields, $price_schema, $styles);
    }
    foreach ($width as $col => $size) {
        if ($size > MAX_SIZE) {
            $size = MAX_SIZE;
        }
        $worksheet->getColumnDimension($col)->setWidth($size);
    }
    $writer = new PHPExcel_Writer_Excel2007($pexcel);
    $imp_filename = fn_create_temp_file();
    $writer->save($imp_filename);
    $pexcel->disconnectWorksheets();
    unset($pexcel);
    Storage::instance('assets')->put($filename, array('file' => $imp_filename, 'caching' => true));
    fn_echo('<br />' . __('done'));
}
/**
 * Checks if server configuration supports xml creation
 *
 * @return bool False if some components are not installed, otherwise True
 */
function fn_price_list_is_xls_supported()
{
    $result = true;
    // check for ZipArchive class exists
    // phpexcel does not work without zip support
    if (!class_exists('ZipArchive')) {
开发者ID:askzap,项目名称:ultimate,代码行数:31,代码来源:xls.php

示例13: writeXlsx


//.........这里部分代码省略.........
                 $oldValue = $rowData[$this->colorChangerColumn];
             }
         } else {
             if ($this->autoZebra) {
                 $changeColor = true;
             }
         }
         if ($changeColor) {
             $cellStyleArray['fill']['color']['argb'] = $this->rainBow->getCurrentAsARGBString();
             $this->rainBow->getNext();
         }
         $i = 0;
         for (; $i < $headCount; $i++) {
             $value = $rowData[$i];
             $coor = XLSWriter::cellCoordinate($i, $row);
             $xlstype = isset($XlsTypes[$i]) ? $XlsTypes[$i] : PHPExcel_Cell_DataType::TYPE_STRING;
             //error_log("writing cell type = {$xlstype} for column {$i}, value {$value}", 0);
             $objPHPExcel->getActiveSheet()->setCellValueExplicit($coor, $value, $xlstype);
             if ($this->columnTypes[$i] == 'date') {
                 $objPHPExcel->getActiveSheet()->getStyle($coor)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2);
             } else {
                 if ($this->columnTypes[$i] == 'time') {
                     $objPHPExcel->getActiveSheet()->getStyle($coor)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME8);
                 }
             }
             $objPHPExcel->getActiveSheet()->getStyle($coor)->applyFromArray($cellStyleArray);
         }
         if ($this->weightedSumsColumn >= 0) {
             $weightLast = count($this->weights) - 1;
             $coor = XLSWriter::cellCoordinate($this->weightedSumsColumn, $row);
             $wBegin = XLSWriter::cellCoordinateAbsoluteRow($this->firstWeightColumn, $this->weigthsRow);
             $wEnd = XLSWriter::cellCoordinateAbsoluteRow($this->firstWeightColumn + $weightLast, $this->weigthsRow);
             $rBegin = XLSWriter::cellCoordinate($this->firstWeightColumn, $row);
             $rEnd = XLSWriter::cellCoordinate($this->firstWeightColumn + $weightLast, $row);
             $wSumCoor = XLSWriter::cellCoordinateAbsolute($this->weightedSumsColumn, $this->weigthsRow);
             $formula = "=SUMPRODUCT({$wBegin}:{$wEnd},{$rBegin}:{$rEnd})/{$wSumCoor}";
             $objPHPExcel->getActiveSheet()->setCellValueExplicit($coor, $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
             $objPHPExcel->getActiveSheet()->getStyle($coor)->applyFromArray($cellStyleArray);
         }
         $row++;
         $resultSet->moveNext();
     }
     $row = 1;
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row, $this->linkText);
     $objPHPExcel->getActiveSheet()->getCell('A' . $row)->getHyperlink()->setUrl($this->linkUrl);
     $row++;
     $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(0, $row, $this->title);
     $objPHPExcel->getActiveSheet()->getStyle('A' . $row)->applyFromArray($headerStyles);
     $objPHPExcel->getActiveSheet()->getStyle('A1')->applyFromArray($headerStyles);
     $rightCell1 = XLSWriter::cellCoordinate(min($headCount - 1, 10), $row);
     $objPHPExcel->getActiveSheet()->mergeCells('A' . $row . ':' . $rightCell1);
     $rightCell2 = XLSWriter::cellCoordinate(min($headCount - 1, 10), 1);
     $objPHPExcel->getActiveSheet()->mergeCells('A1:' . $rightCell2);
     // set format
     $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
     $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
     $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToWidth(1);
     $objPHPExcel->getActiveSheet()->getPageSetup()->setFitToHeight(0);
     for ($i = 'A', $j = 0; $i <= 'Z' && $j < $headCount; $i++, $j++) {
         $objPHPExcel->getActiveSheet()->getColumnDimension($i)->setAutoSize(true);
         //            $objPHPExcel->getActiveSheet()->getStyle($i . '2')->applyFromArray($styleArray);
     }
     PHPExcel_Calculation::getInstance()->clearCalculationCache();
     PHPExcel_Calculation::getInstance()->disableCalculationCache();
     PHPExcel_Calculation::getInstance()->calculate();
     switch ($this->excelFormat) {
         case 'Excel2007':
             $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
             $this->mimeType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
             break;
         case 'Excel5':
             $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
             $this->mimeType = 'application/vnd.ms-excel';
             break;
         default:
             $objWriter = new PHPExcel_Writer_CSV($objPHPExcel);
             $this->mimeType = 'text/comma-separated-values';
             break;
     }
     $tempFile = tempnam('/tmp/', 'PHPEXCEL');
     // '/tmp/'.$filename;
     $objWriter->setPreCalculateFormulas(true);
     $objWriter->save($tempFile);
     $fp = @fopen($tempFile, 'r');
     if ($fp != false) {
         header("Content-type: " . $this->mimeType);
         header("Pragma: public");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Content-Length: " . filesize($tempFile));
         header("Content-Disposition: attachment; filename=\"{$this->filename}\"");
         fpassthru($fp);
         fclose($fp);
         $objPHPExcel->disconnectWorksheets();
         unset($objPHPExcel);
         unlink($tempFile);
         exit(0);
     } else {
         echo "cannot copy file {$tempFile} to out stream\n";
     }
 }
开发者ID:homberghp,项目名称:peerweb,代码行数:101,代码来源:queryToXlsx.php

示例14: array2excel

 public function array2excel($data, $output = true)
 {
     //数组转换为excel文件
     $PHPExcel = new PHPExcel();
     $WorkSheet = $PHPExcel->getActiveSheet();
     set_time_limit(0);
     @ini_set('memory_limit', '256M');
     $row_index = 1;
     foreach ($data as $row) {
         //循环赋值
         $col_index = 0;
         foreach ($row as $col) {
             $WorkSheet->setCellValueByColumnAndRow($col_index, $row_index, $col);
             $col_index++;
         }
         $row_index++;
     }
     $Writer = new PHPExcel_Writer_Excel5($PHPExcel);
     $filename = time();
     if ($output) {
         header("Content-Type: application/force-download");
         header("Content-Type: application/octet-stream");
         header("Content-Type: application/download");
         header('Content-Disposition:inline;filename="' . $filename . '.xls"');
         header("Content-Transfer-Encoding: binary");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Pragma: no-cache");
         $Writer->save('php://output');
         //直接输出
     } else {
         $Writer->save($filename . '.xls');
         //生成为文件
     }
     $PHPExcel->disconnectWorksheets();
     unset($PHPExcel);
 }
开发者ID:zhouzhouxs,项目名称:Progect,代码行数:36,代码来源:excel.class.php

示例15: saveArchiveFile

 /**
  * Save generated archive file or trigger a direct download if class var
  * $direct_download_archive is set to true
  * @param PHPExcel $obj_excel
  * @param String $period
  * @param String $table_name
  * @param Int $file_counter
  * @param Boolean $clear_excel_object_from_memory
  */
 private static function saveArchiveFile($obj_excel, $period, $table_name, $use_timestamp_as_prefix = true, $file_counter = null, $clear_excel_object_from_memory = true)
 {
     $save_path = self::generateArchiveFilepath($period, $table_name, $use_timestamp_as_prefix, $file_counter);
     $obj_excel_writer = new PHPExcel_Writer_Excel5($obj_excel);
     if (self::$direct_download_archive) {
         $filename = basename($save_path);
         header("Content-Type: application/vnd.ms-excel");
         header("Content-Disposition: attachment; filename={$filename}");
         $obj_excel_writer->save('php://output');
     } else {
         $obj_excel_writer->save($save_path);
         self::$archive_files[$period][$table_name] = str_replace(DIR_FS_ARCHIVES . self::ARCHIVE_PATH, '', $save_path);
     }
     if ($clear_excel_object_from_memory) {
         $obj_excel->disconnectWorksheets();
         unset($obj_excel_writer, $obj_excel);
     } else {
         unset($obj_excel_writer);
     }
 }
开发者ID:blasiuscosa,项目名称:manobo-2008,代码行数:29,代码来源:ReportBookkeeping.php


注:本文中的PHPExcel::disconnectWorksheets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。