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


PHP PHPExcel_Settings::setCacheStorageMethod方法代码示例

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


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

示例1: exportXlsx

 public static function exportXlsx($data, $keys)
 {
     // Create new PHPExcel object
     $objPHPExcel = new \PHPExcel();
     // Set document properties
     $objPHPExcel->getProperties()->setCreator("Roadiz CMS")->setLastModifiedBy("Roadiz CMS")->setCategory("");
     $cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
     $cacheSettings = ['memoryCacheSize' => '8MB'];
     \PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
     $objPHPExcel->setActiveSheetIndex(0);
     foreach ($keys as $key => $value) {
         $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($key, 1, $value);
     }
     foreach ($data as $key => $answer) {
         foreach ($answer as $k => $value) {
             $columnAlpha = \PHPExcel_Cell::stringFromColumnIndex($k);
             if ($value instanceof \DateTime) {
                 $value = \PHPExcel_Shared_Date::PHPToExcel($value);
                 $objPHPExcel->getActiveSheet()->getStyle($columnAlpha . (2 + $key))->getNumberFormat()->setFormatCode('dd.mm.yyyy hh:MM:ss');
             }
             $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($k, 2 + $key, $value);
         }
     }
     // Set active sheet index to the first sheet, so Excel opens this as the first sheet
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
     ob_start();
     $objWriter->save('php://output');
     $return = ob_get_clean();
     return $return;
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:30,代码来源:XlsxExporter.php

示例2: __construct

 /**
  * @param string $dirName Target directory for xls files
  */
 public function __construct($dirName)
 {
     $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
     $cacheSettings = array('memoryCacheSize' => '512MB');
     PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
     $this->filename = realpath($dirName . '/') . date("dmY-His") . "_" . uniqid() . ".xlsx";
     $this->objPHPExcel = new PHPExcel();
 }
开发者ID:glendemon,项目名称:phpexcel-wrapper,代码行数:11,代码来源:PhpExcelWrapper.php

示例3: __construct

 public function __construct()
 {
     $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
     $cacheSettings = array(' memoryCacheSize ' => '8MB');
     PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
     $this->phpExcel = new PHPExcel();
 }
开发者ID:jesse108,项目名称:admin_base,代码行数:7,代码来源:Excel.class.php

示例4: __construct

 /**
  *
  * @do 构造函数
  *
  * @access public 
  * @author Nick
  * @copyright rockhippo
  * @param -
  * @return -
  *
  */
 public function __construct()
 {
     $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;
     PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
     //创建一个处理对象实例
     $this->objPHPExcel = new PHPExcel();
 }
开发者ID:haitao1880,项目名称:study,代码行数:18,代码来源:XPhpExcel.php

示例5: configExcel

 private function configExcel($pParamHash)
 {
     // config PHPExcel
     // cache method
     switch ($this->getConfig('cache_method')) {
         case 'cache_to_discISAM':
             $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
             break;
         case 'cache_in_memory_serialized':
             $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;
             break;
         case 'cache_in_memory':
         default:
             $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory;
             break;
     }
     PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
     // create excel object
     if (!isset($this->mPHPExcel)) {
         $this->mPHPExcel = new PHPExcel();
     }
     // set doc properties
     $this->mPHPExcel->getProperties()->setTitle($pParamHash['workbook']['title']);
     // $this->mPHPExcel->getProperties()->setCreator("Maarten Balliauw");
     // $this->mPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
     // $this->mPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
     // $this->mPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");
 }
开发者ID:shen0834,项目名称:util,代码行数:28,代码来源:BitExcel.php

示例6: stream_open

 /**
  * @inheritdoc
  */
 public function stream_open($path, $mode, $options, &$opened_path)
 {
     \PHPExcel_Settings::setCacheStorageMethod(\PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3);
     $this->objPHPExcel = new \PHPExcel();
     $this->sheet = $this->objPHPExcel->getActiveSheet();
     $this->offset = 1;
     return parent::stream_open($path, $mode, $options, $opened_path);
 }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:11,代码来源:XlsRendererStream.php

示例7: __construct

 public function __construct($file_path)
 {
     require_once "../app/classes/PHPExcel.php";
     #将单元格序列化后再进行Gzip压缩,然后保存在内存中
     PHPExcel_Settings::setCacheStorageMethod(PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip);
     $file_type = PHPExcel_IOFactory::identify($file_path);
     $objReader = PHPExcel_IOFactory::createReader($file_type);
     self::$objPHPExcel = $objReader->load($file_path);
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:9,代码来源:ExcelUpload.php

示例8: exportXLSX

 public function exportXLSX(Repository $repository, $contentTypeName, $workspace = 'default', $language = 'default', $viewName = 'exchange')
 {
     $repository->selectContentType($contentTypeName);
     // Select view and fallback if necessary
     $contentTypeDefinition = $repository->getContentTypeDefinition();
     $viewDefinition = $contentTypeDefinition->getExchangeViewDefinition($viewName);
     $viewName = $viewDefinition->getName();
     $this->writeln('Connecting repository');
     $this->writeln('');
     $repository->selectWorkspace($workspace);
     $repository->selectLanguage($language);
     $repository->selectView($viewName);
     /** @var Record[] $records */
     $records = $repository->getRecords('', '.id', 1);
     if ($records !== false) {
         // Create new PHPExcel object
         $objPHPExcel = new \PHPExcel();
         // use temp folder for processing of large files
         $cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
         $cacheSettings = array('memoryCacheSize' => '12MB');
         \PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
         // Set document properties
         $objPHPExcel->getProperties()->setCreator("AnyContent CMCK")->setLastModifiedBy("AnyContent CMCK")->setTitle("Full Export from content type " . $contentTypeDefinition->getTitle())->setSubject("AnyContent Export")->setDescription("");
         $worksheet = $objPHPExcel->setActiveSheetIndex(0);
         $worksheet->setTitle('Export');
         $worksheet->setCellValueByColumnAndRow(0, 1, '.id');
         $worksheet->getStyleByColumnAndRow(0, 1)->getFont()->setBold(false)->setItalic(true);
         $worksheet->setCellValueByColumnAndRow(1, 1, '.revision');
         $worksheet->getStyleByColumnAndRow(1, 1)->getFont()->setBold(false)->setItalic(true);
         $row = 1;
         $column = 2;
         foreach ($contentTypeDefinition->getProperties($viewName) as $property) {
             $worksheet->setCellValueByColumnAndRow($column, $row, $property);
             $worksheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true);
             $worksheet->getColumnDimensionByColumn($column)->setWidth(20);
             $column++;
         }
         $row++;
         foreach ($records as $record) {
             $this->writeln('Processing record ' . $record->getID() . ' - ' . $record->getName());
             $worksheet->setCellValueByColumnAndRow(0, $row, $record->getID());
             $worksheet->setCellValueByColumnAndRow(1, $row, $record->getRevision());
             $column = 2;
             foreach ($contentTypeDefinition->getProperties($viewName) as $property) {
                 $worksheet->setCellValueByColumnAndRow($column, $row, $record->getProperty($property));
                 $column++;
             }
             $row++;
         }
         $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
         ob_start();
         $objWriter->save('php://output');
         $excelOutput = ob_get_clean();
         return $excelOutput;
     }
     return false;
 }
开发者ID:nhagemann,项目名称:anycontent-cms-construction-kit-php,代码行数:57,代码来源:Exporter.php

示例9: setData

 public function setData()
 {
     $excel_cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
     $excel_cacheSettings = ['memoryCacheSize ' => '128MB'];
     \PHPExcel_Settings::setCacheStorageMethod($excel_cacheMethod, $excel_cacheSettings);
     $excel = \PHPExcel_IOFactory::load(\Yii::$app->getModule('data')->importDir . '/' . $this->filename);
     $data = $excel->getActiveSheet()->toArray();
     unset($excel);
     return $data;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:10,代码来源:ImportXlsx.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: load_resource_sheets

 private function load_resource_sheets()
 {
     $this->write_log(' Starting reading excel file, this may take minutes, please wait....');
     $file_resource_path = $this->file_directory . $this->file_resource_name;
     if (file_exists($file_resource_path)) {
         $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
         $cacheSettings = array('memoryCacheSize' => '2GB');
         PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
         $reader = PHPExcel_IOFactory::createReader('Excel2007');
         $reader->setReadDataOnly(true);
         $this->objPHPExcel_resource = $reader->load($file_resource_path);
     }
     $this->write_log(' File read. starting convert:');
 }
开发者ID:smallyin,项目名称:ci-phpexcel,代码行数:14,代码来源:reader.php

示例12: __construct

 /**
  * MySqlExcelBuilder::__construct()
  * 
  * @param mixed $db  - Database
  * @param mixed $un  - User name
  * @param mixed $pw  - Password
  * 
  */
 public function __construct($db, $un, $pw)
 {
     $host = 'localhost';
     $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory;
     PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
     $this->phpExcel = new PHPExcel();
     $dsn = "mysql:host={$host};port=3306;dbname={$db}";
     try {
         $this->pdo = new PDO($dsn, $un, $pw);
         $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
     } catch (PDOException $e) {
         $this->{$pdo} = null;
         error_log("{$dsn}\n" . 'Connection failed: ' . $e->getMessage());
     }
 }
开发者ID:n1exceptme,项目名称:energia,代码行数:23,代码来源:MySqlExcelBuilder.php

示例13: format

 /**
  * Formats the specified response.
  * @param \yii\web\Response $response the response to be formatted.
  */
 public function format($response)
 {
     //$response->getHeaders()->set('Content-Type', 'application/vnd.ms-excel');
     $response->setDownloadHeaders(basename(\Yii::$app->request->pathInfo) . '.xls', 'application/vnd.ms-excel');
     if ($response->data === null) {
         return;
     }
     \PHPExcel_Settings::setCacheStorageMethod(\PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3);
     $styles = $this->getStyles();
     $objPHPExcel = new \PHPExcel();
     $sheet = $objPHPExcel->getActiveSheet();
     $offset = 1;
     /*
      * serialize filter
     $sheet->setCellValue('A1', $opcje['nazwaAnaliza']);
     $sheet->duplicateStyle($styles['default'], 'A1:C4');
     $sheet->getRowDimension(1)->setRowHeight(18);
     $sheet->getStyle('A1')->getFont()->setBold(true)->setSize(15);
     $sheet->getStyle('C3:C4')->getFont()->setBold(true);
     $offset = 6;
     */
     $data = $response->data;
     if (!isset($data['items'])) {
         // single model
         $this->addLine($sheet, $offset, array_keys($data));
         $this->addLine($sheet, $offset + 1, array_values($data));
         for ($i = 1, $lastColumn = 'A'; $i < count($data); $i++, $lastColumn++) {
         }
         $sheet->duplicateStyle($styles['header'], 'A' . $offset . ':' . $lastColumn . $offset);
     } else {
         // a collection of models
         if (($firstRow = reset($data['items'])) !== false) {
             $this->addLine($sheet, $offset, array_keys($firstRow));
         }
         $startOffset = ++$offset;
         $item = [];
         foreach ($data['items'] as $item) {
             $this->addLine($sheet, $offset++, $item);
         }
         $this->addSummaryRow($sheet, $startOffset, $offset, $item);
     }
     $filename = tempnam(\Yii::getAlias('@runtime'), 'xls');
     $objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel);
     $objWriter->save($filename);
     $response->content = file_get_contents($filename);
     unlink($filename);
 }
开发者ID:netis-pl,项目名称:yii2-crud,代码行数:51,代码来源:XlsResponseFormatter.php

示例14: __construct

 function __construct($nom_archivo, $titulo)
 {
     //ini_set('memory_limit','512M');
     set_time_limit(400);
     $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
     $cacheSettings = array('memoryCacheSize' => '10MB');
     PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
     $this->docexcel = new PHPExcel();
     /*"../../reportes_generados/$nom_archivo");*/
     $this->docexcel->getProperties()->setCreator("XPHS")->setLastModifiedBy("XPHS")->setTitle($titulo)->setSubject($titulo)->setDescription('Reporte "' . $titulo . '", generado por el framework XPHS')->setKeywords("office 2007 openxml php")->setCategory("Report File");
     $this->docexcel->setActiveSheetIndex(0);
     $this->docexcel->getActiveSheet()->setTitle($titulo);
     $this->nombre_archivo = $nom_archivo;
     $this->titulo = $titulo;
     $this->fila = 1;
     $this->equivalencias = array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E', 5 => 'F', 6 => 'G', 7 => 'H', 8 => 'I', 9 => 'J', 10 => 'K', 11 => 'L', 12 => 'M', 13 => 'N', 14 => 'O', 15 => 'P', 16 => 'Q', 17 => 'R', 18 => 'S', 19 => 'T', 20 => 'U', 21 => 'V', 22 => 'W', 23 => 'X', 24 => 'Y', 25 => 'Z', 26 => 'AA', 27 => 'AB', 28 => 'AC', 29 => 'AD', 30 => 'AE', 31 => 'AF', 32 => 'AG', 33 => 'AH', 34 => 'AI', 35 => 'AJ', 36 => 'AK', 37 => 'AL', 38 => 'AM', 39 => 'AN', 40 => 'AO', 41 => 'AP', 42 => 'AQ', 43 => 'AR', 44 => 'AS', 45 => 'AT', 46 => 'AU', 47 => 'AV', 48 => 'AW', 49 => 'AX', 50 => 'AY', 51 => 'AZ', 52 => 'BA', 53 => 'BB', 54 => 'BC', 55 => 'BD', 56 => 'BE', 57 => 'BF', 58 => 'BG', 59 => 'BH', 60 => 'BI', 61 => 'BJ', 62 => 'BK', 63 => 'BL', 64 => 'BM', 65 => 'BN', 66 => 'BO', 67 => 'BP', 68 => 'BQ', 69 => 'BR', 70 => 'BS', 71 => 'BT', 72 => 'BU', 73 => 'BV', 74 => 'BW', 75 => 'BX', 76 => 'BY', 77 => 'BZ');
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:17,代码来源:ReporteXLS.php

示例15: read

 public function read($filePath, $type = 'xls')
 {
     $readerObj = null;
     $type = strtolower($type);
     \PHPExcel_Settings::setCacheStorageMethod(\PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip, array());
     if ($type == 'xls') {
         $readerObj = $this->_getImportExtendInstanceForXls();
     } else {
         if ($type == 'xlsx') {
             $readerObj = $this->_getImportExtendInstanceForXlsx();
         }
     }
     if (empty($readerObj)) {
         return false;
     }
     $excelExtendObj = $readerObj->load($filePath);
     if ($excelExtendObj->getSheetCount() < 1) {
         return false;
     }
     $allData = array();
     foreach ($excelExtendObj->getAllSheets() as $sheet) {
         $sheetData = $sheet->toArray();
         $dataCount = count($sheetData);
         if ($dataCount <= 1) {
             continue;
         }
         $fields = array();
         $dataSet = array();
         foreach ($sheetData as $rowIndex => $rowData) {
             foreach ($rowData as $cellIndex => $cellValue) {
                 if ($rowIndex == 0) {
                     $fields[$cellIndex] = $cellValue;
                 } else {
                     if (!isset($dataSet[$rowIndex - 1])) {
                         $dataSet[$rowIndex - 1] = array();
                     }
                     $dataSet[$rowIndex - 1][$fields[$cellIndex]] = $rowData[$cellIndex];
                 }
             }
         }
         $title = trim($sheet->getTitle());
         $allData[$title] = $dataSet;
     }
     return $allData;
 }
开发者ID:qycloud,项目名称:ant_utils,代码行数:45,代码来源:Excel.php


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