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


PHP PHPExcel_Writer_Excel2007::save方法代码示例

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


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

示例1: toExcel

 public function toExcel($SiteName, $StrarTime, $FinshTime)
 {
     /** Error reporting */
     error_reporting(E_ALL);
     /** Include path **/
     ini_set('include_path', ini_get('include_path') . ';../Classes/');
     /** PHPExcel */
     include 'PHPExcel.php';
     /** PHPExcel_Writer_Excel2007 */
     include 'PHPExcel/Writer/Excel2007.php';
     // Create new PHPExcel object
     // echo date('H:i:s') . " Create new PHPExcel object\n";
     $objPHPExcel = new PHPExcel();
     // Set properties
     // echo date('H:i:s') . " Set properties\n";
     $objPHPExcel->getProperties()->setCreator("Chen Po Hsun");
     $objPHPExcel->getProperties()->setLastModifiedBy("Po Hsun");
     $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
     $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
     $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
     // Add some data
     // echo date('H:i:s') . " Add some data\n";
     $time_diff = (strtotime($time1) - strtotime($time2)) / (60 * 60) + 1;
     $begin = 2;
     $objPHPExcel->setActiveSheetIndex(0);
     $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'SiteName');
     $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Country!');
     $objPHPExcel->getActiveSheet()->SetCellValue('D1', 'PM2.5');
     $objPHPExcel->getActiveSheet()->SetCellValue('E1', 'PM10');
     $objPHPExcel->getActiveSheet()->SetCellValue('F1', 'CO');
     $data['query'] = $this->sql->select_site($SiteName, $StrarTime);
     while ($begin < $time_diff + 2) {
         $objPHPExcel->getActiveSheet()->SetCellValue('B1', $data['SiteName']);
         $objPHPExcel->getActiveSheet()->SetCellValue('C1', $data['Country']);
         $objPHPExcel->getActiveSheet()->SetCellValue('D1', $data['PM2.5']);
         $objPHPExcel->getActiveSheet()->SetCellValue('E1', $data['PM10']);
         $objPHPExcel->getActiveSheet()->SetCellValue('F1', $data['CO']);
         $objPHPExcel->getActiveSheet()->SetCellValue('A$begin', $data['PublishTime']);
         $begin++;
         $data['query'] = $this->sql->select_site($SiteName, $FinshTime);
     }
     // Rename sheet
     // echo date('H:i:s') . " Rename sheet\n";
     $objPHPExcel->getActiveSheet()->setTitle('Test');
     // Save Excel 2007 file
     // echo date('H:i:s') . " Write to Excel2007 format\n";
     $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
     $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
     // Echo done
     // echo date('H:i:s') . " Done writing file.\r\n";
 }
开发者ID:PHChenGit,项目名称:PM25,代码行数:51,代码来源:OutputFile.php

示例2: display

 function display()
 {
     global $current_user;
     $c = range('A', 'Z');
     // Create new PHPExcel object
     $objPHPExcel = new PHPExcel();
     // set column size to auto
     foreach ($c as $columnID) {
         $objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setAutoSize(true);
     }
     // Set properties
     $objPHPExcel->getProperties()->setCreator($current_user->display_name);
     $objPHPExcel->getProperties()->setLastModifiedBy($current_user->display_name);
     $objPHPExcel->getProperties()->setTitle($this->title);
     $objPHPExcel->getProperties()->setSubject($this->subject);
     $objPHPExcel->getProperties()->setDescription($this->description);
     // Add some data
     $objPHPExcel->setActiveSheetIndex(0);
     // table header
     $x = 0;
     foreach ($this->cols as $v) {
         $objPHPExcel->getActiveSheet()->SetCellValue($c[$x] . '1', $v)->getStyle($c[$x] . '1')->getFont()->setBold(true);
         // A1, B1, etc
         $x++;
     }
     // table row
     foreach ($this->data as $i => $item) {
         $j = $i + 2;
         // A2, B2, etc
         $x = 0;
         $index = $i + 1;
         $item->index = 0;
         foreach ($this->cols as $column_name => $v) {
             if ($column_name == 'index') {
                 $item->index = 10;
             }
             #$val = $item->$column_name;
             $method = 'column_' . $column_name;
             if (method_exists($this->table_obj, $method)) {
                 $val = $this->table_obj->{$method}($item, $column_name);
             } else {
                 $val = $this->table_obj->column_default($item, $column_name);
             }
             $objPHPExcel->getActiveSheet()->SetCellValue($c[$x] . $j, $val, $format);
             $x++;
         }
     }
     $objPHPExcel->getActiveSheet()->setTitle('Sheet 1');
     $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
     header('Content-type: application/vnd.ms-excel');
     header('Content-Disposition: attachment; filename="' . $this->filename . '"');
     $objWriter->save('php://output');
     exit;
 }
开发者ID:xflash8,项目名称:staff-2016,代码行数:54,代码来源:excel.class.php

示例3: flush

 public function flush()
 {
     if (!$this->active) {
         return;
     }
     $this->outputResponse->setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     $writer = new \PHPExcel_Writer_Excel2007($this->excelDoc);
     $tempFile = tempnam(sys_get_temp_dir(), 'NiysuExcel');
     $writer->save($tempFile);
     $this->outputResponse->appendData(file_get_contents($tempFile));
     unlink($tempFile);
 }
开发者ID:tomaka17,项目名称:niysu,代码行数:12,代码来源:PHPExcelOutput.php

示例4: tempnam

 /**
  * Outputs export footer
  *
  * @return  bool        Whether it suceeded
  *
  * @access  public
  */
 function PMA_exportFooter()
 {
     global $workbook;
     global $tmp_filename;
     $tmp_filename = tempnam(realpath($GLOBALS['cfg']['TempDir']), 'pma_xlsx_');
     $workbookWriter = new PHPExcel_Writer_Excel2007($workbook);
     $workbookWriter->save($tmp_filename);
     if (!PMA_exportOutputHandler(file_get_contents($tmp_filename))) {
         return FALSE;
     }
     unlink($tmp_filename);
     unset($GLOBALS['workbook']);
     unset($GLOBALS['sheet_index']);
     return TRUE;
 }
开发者ID:hackdracko,项目名称:envasadoras,代码行数:22,代码来源:xlsx.php

示例5: output

 public function output()
 {
     $writer = new PHPExcel_Writer_Excel2007($this->spreadsheet);
     $file = "app/temp/" . uniqid() . "_report.xlsx";
     $writer->save($file);
     Application::redirect("/{$file}");
 }
开发者ID:ekowabaka,项目名称:wyf,代码行数:7,代码来源:XlsRenderer.php

示例6: getBuffer

 /**
  * Dumps XLS file to memory & retrieves content
  * @param \PHPExcel $xls
  * @return string
  */
 private function getBuffer(\PHPExcel $xls)
 {
     ob_start();
     $writer = new \PHPExcel_Writer_Excel2007($xls);
     $writer->save('php://output');
     return ob_get_clean();
 }
开发者ID:vegas-cmf,项目名称:exporter,代码行数:12,代码来源:Xls.php

示例7: finalize

 public function finalize()
 {
     $writer = new \PHPExcel_Writer_Excel2007($this->excel);
     $writer->setPreCalculateFormulas(false);
     $writer->save($this->filename);
     return $this->filename;
 }
开发者ID:csanquer,项目名称:fakery-generator,代码行数:7,代码来源:ExcelDumper.php

示例8: header

 function _output($title)
 {
     header('Content-Type: application/vnd.openXMLformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="' . $title . '.xlsx"');
     header('Cache-Control: max-age=0');
     $objWriter = new PHPExcel_Writer_Excel2007($this->xls);
     $objWriter->save('php://output');
     exit;
 }
开发者ID:skydel,项目名称:universal-online-exam,代码行数:9,代码来源:ExcelHelper.php

示例9: xlsToXslx

function xlsToXslx($file_name_input, $file_name_output)
{
    try {
        $objPHPexcel = PHPExcel_IOFactory::load($file_name_input);
        $objWriter = new PHPExcel_Writer_Excel2007($objPHPexcel);
        $objWriter->setOffice2003Compatibility(true);
        $objWriter->save($file_name_output);
        return true;
    } catch (Exception $e) {
        return false;
    }
}
开发者ID:ViktorKITP,项目名称:schedule,代码行数:12,代码来源:xlsToXlsx.php

示例10: create_worksheet

 public function create_worksheet($excel_data = NUll)
 {
     //check if the excel data has been set if not exit the excel generation
     if (count($excel_data) > 0) {
         //echo "<pre/>";
         //print_r($excel_data);
         $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
         $cacheSettings = array('memoryCacheSize' => '2MB');
         PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
         ini_set('max_execution_time', 123456);
         $objPHPExcel = new PHPExcel();
         $objPHPExcel->getProperties()->setCreator("CD4");
         $objPHPExcel->getProperties()->setLastModifiedBy($excel_data['doc_creator']);
         $objPHPExcel->getProperties()->setTitle($excel_data['doc_title']);
         $objPHPExcel->getProperties()->setSubject($excel_data['doc_title']);
         $objPHPExcel->getProperties()->setDescription("");
         // Add some data
         //	echo date('H:i:s') . " Add some data\n";
         $objPHPExcel->setActiveSheetIndex(0);
         $rowExec = 1;
         //Looping through the cells
         $column = 0;
         // foreach ($excel_data['column_data'] as $cell) {
         // 	$objPHPExcel -> getActiveSheet() -> setCellValueByColumnAndRow($column, $rowExec, $cell);
         // 	$objPHPExcel -> getActiveSheet() -> getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($column)) -> setAutoSize(true);
         // 	$column++;
         // }
         // $rowExec = 2;
         // $column = 0;
         // foreach ($excel_data['row_data'] as $cell) {
         // //Looping through the cells per facility
         // 	$objPHPExcel -> getActiveSheet() -> setCellValueByColumnAndRow($column, $rowExec, $cell);
         // 	$rowExec++;
         // 	$column++;
         // }
         $objPHPExcel->getActiveSheet()->fromArray($excel_data['row_data'], NULL, 'A1');
         // Rename sheet
         //	echo date('H:i:s') . " Rename sheet\n";
         $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('Content-type: application/vnd.ms-excel');
         // It will be called file.xls
         header("Content-Disposition: attachment; filename=" . $excel_data['file_name']);
         // Write file to the browser
         $objWriter->save('php://output');
         // Echo done
     }
 }
开发者ID:OmondiKevin,项目名称:CD4,代码行数:51,代码来源:worksheets.php

示例11: render

 /**
  *
  */
 public function render()
 {
     $excel = new \PHPExcel();
     $excel->getDefaultStyle()->getFont()->setName('Arial');
     $excel->getDefaultStyle()->getFont()->setSize(10);
     $this->_sheet = $excel->getActiveSheet();
     $this->_sheet->setTitle($this->_tabs_title);
     $this->_sheet->getTabColor()->setARGB('FFc3e59e');
     $this->_sheet->fromArray($this->makeExportData());
     //resize
     $this->excelWidth();
     //height header
     header('Content-Type: application/excel');
     header('Content-Disposition: attachment; filename="' . $this->getFile() . '"');
     header('Cache-Control: max-age=0');
     $writer = new \PHPExcel_Writer_Excel2007($excel);
     $writer->save('php://output');
 }
开发者ID:defan-marunchak,项目名称:eurotax,代码行数:21,代码来源:Excel.php

示例12: downloadAction

 /**
  * @return array
  */
 public function downloadAction()
 {
     if (!$this->isGranted('event.entries')) {
         return $this->redirect()->toRoute('home');
     }
     $id = (int) $this->params()->fromRoute('id');
     $trial = $this->getRepository()->find($id);
     if (!$trial || !$trial->getEvent()->isApproved()) {
         return $this->notFoundAction();
     }
     $scoreSheet = $this->getEventService()->createScoreSheet($trial);
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment; filename=\'USCSS Trial Score Sheet - ' . $trial . '.xlsx\'');
     header('Cache-Control: max-age=0');
     $output = new \PHPExcel_Writer_Excel2007($scoreSheet);
     $output->save('php://output');
     return $this->getResponse();
 }
开发者ID:PoetikDragon,项目名称:USCSS,代码行数:21,代码来源:TrialController.php

示例13: summaryReportAction

 public function summaryReportAction($year, $quarter)
 {
     $periodMananger = $this->get('wealthbot_ria.period.manager');
     $reportMananger = $this->get('wealthbot_ria.billing_report.manager');
     // Generate report
     $periods = $periodMananger->getQuarterPeriod($year, $quarter);
     $excel = $reportMananger->generateSummary($periods);
     // Generate filename
     $periods = array_keys($periods);
     $quarter = empty($quarter) ? min($periods) . '-' . max($periods) : $quarter;
     $filename = "billing_summary_q{$quarter}_{$year}";
     $response = new Response();
     $response->headers->add(array('Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'Content-Disposition' => 'attachment;filename="' . $filename . '.xlsx"', 'Cache-Control' => 'max-age=0'));
     ob_start();
     $writer = new \PHPExcel_Writer_Excel2007($excel);
     $writer->save('php://output');
     $response->setContent(ob_get_clean());
     return $response;
 }
开发者ID:junjinZ,项目名称:wealthbot,代码行数:19,代码来源:BillingController.php

示例14: write

 /**
  * Для записи в файл таблиц использует библиотеку PHPExcell. Также копирует картинки в папку out/images/ с изменением имени.
  * @param array $products
  * @param string $imagesInDir
  * @param string $imagesOutDir
  */
 public function write(array $products, $imagesInDir, $imagesOutDir)
 {
     $excelDoc = new \PHPExcel();
     $excelDoc->setActiveSheetIndex();
     $activeSheet = $excelDoc->getActiveSheet();
     $activeSheet->setTitle("Таблица товаров");
     //Записываем заголовок
     $col = 'A';
     foreach (self::header as $headerElem => $elemWidth) {
         $activeSheet->setCellValue($col . 1, $headerElem);
         $activeSheet->getColumnDimension($col++)->setWidth($elemWidth * WIDTH_MULTIPLIER);
     }
     $activeSheet->freezePane('A2');
     //записываем информацию о товарах
     foreach ($products as $index => $product) {
         $activeSheet->setCellValue('A' . ($index + 2), $index + 1);
         //Номер товара
         $activeSheet->setCellValue('B' . ($index + 2), 1);
         // Тип товара
         $activeSheet->setCellValue('C' . ($index + 2), $product->category->name);
         // Категория
         $activeSheet->setCellValue('D' . ($index + 2), sprintf("%s;%s;%s", $product->manufacturer->name, $product->manufacturer->country, $product->manufacturer->url));
         $activeSheet->setCellValue('E' . ($index + 2), $product->name);
         // Название
         $activeSheet->setCellValue('F' . ($index + 2), $product->ingredients);
         // Состав
         $activeSheet->setCellValue('G' . ($index + 2), $product->shortDescr);
         // Краткое описание
         $activeSheet->setCellValue('H' . ($index + 2), '');
         // Полное описание
         $activeSheet->setCellValue('I' . ($index + 2), $product->keywords);
         // Ключевые слова
         $activeSheet->setCellValue('J' . ($index + 2), $product->price);
         // Цена
         $activeSheet->setCellValue('K' . ($index + 2), $product->sale);
         // Скидка
         $this->writeImages($product, $index + 1, $imagesInDir, $imagesOutDir);
     }
     //Сохраняем файл таблиц на диске
     $docWriter = new \PHPExcel_Writer_Excel2007($excelDoc);
     $docWriter->save($this->fileName);
 }
开发者ID:blackneck,项目名称:EcoStore,代码行数:48,代码来源:XLSXWriter.php

示例15: dump

 /**
  * Dumps the stats table
  * @param  StatsTable $statsTable
  * @return string
  */
 public function dump(StatsTable $statsTable)
 {
     $excel = new \PHPExcel();
     $excel->getDefaultStyle()->applyFromArray($this->getDefaultStyleArray());
     $sheet = $excel->getSheet();
     $row = 1;
     $data = $statsTable->getData();
     $width = count(reset($data));
     // HEADERS //
     if ($this->enableHeaders) {
         $headerStyle = new \PHPExcel_Style();
         $headerStyle->applyFromArray($this->getHeadersStyleArray());
         $col = 0;
         foreach ($statsTable->getHeaders() as $header) {
             $sheet->setCellValueByColumnAndRow($col, $row, $header);
             $col++;
         }
         $sheet->duplicateStyle($headerStyle, 'A1:' . \PHPExcel_Cell::stringFromColumnIndex($width - 1) . '1');
         $row++;
     }
     // DATA //
     foreach ($statsTable->getData() as $data) {
         $this->applyValues($sheet, $row, $data, $statsTable->getDataFormats());
         $row++;
     }
     // AGGREGATIONS //
     if ($this->enableAggregation) {
         $this->applyValues($sheet, $row, $statsTable->getAggregations(), $statsTable->getAggregationsFormats(), $this->getAggregationsStyleArray());
     }
     // FINAL FORMATTING //
     for ($col = 0; $col < $width; $col++) {
         $sheet->getColumnDimension(\PHPExcel_Cell::stringFromColumnIndex($col))->setAutoSize(true);
     }
     $xlsDumper = new \PHPExcel_Writer_Excel2007($excel);
     $pFilename = @tempnam(\PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
     $xlsDumper->save($pFilename);
     $contents = file_get_contents($pFilename);
     @unlink($pFilename);
     unset($excel);
     unset($xlsDumper);
     return $contents;
 }
开发者ID:igraal,项目名称:stats-table,代码行数:47,代码来源:ExcelDumper.php


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