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


PHP PHPExcel_IOFactory::addSearchLocation方法代码示例

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


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

示例1: woo_cd_load_phpexcel_sed_csv_writer

function woo_cd_load_phpexcel_sed_csv_writer() {

	if( class_exists( 'PHPExcel_IOFactory' ) ) {
		PHPExcel_IOFactory::addSearchLocation( 'IWriter', WOO_CD_PATH . 'includes/export-csv.php', 'PHPExcel_Writer_SED_CSV_{0}' );
	} else {
		return false;
	}

	/** My custom writer */
	class PHPExcel_Writer_SED_CSV extends PHPExcel_Writer_CSV {
	
		/**
		 * PHPExcel object
		 *
		 * @var PHPExcel
		 */
		private $_phpExcel;
	
		/**
		 * Delimiter
		 *
		 * @var string
		 */
		private $_delimiter	= ',';
	
		/**
		 * Enclosure
		 *
		 * @var string
		 */
		private $_enclosure	= '"';
	
		/**
		 * Line ending
		 *
		 * @var string
		 */
		private $_lineEnding	= PHP_EOL;
	
		/**
		 * Sheet index to write
		 *
		 * @var int
		 */
		private $_sheetIndex	= 0;
	
		/**
		 * Whether to write a BOM (for UTF8).
		 *
		 * @var boolean
		 */
		private $_useBOM = false;
	
		/**
		 * Whether to write a fully Excel compatible CSV file.
		 *
		 * @var boolean
		 */
		private $_excelCompatibility = false;
	
		/**
		 * Create a new PHPExcel_Writer_CSV
		 *
		 * @param	PHPExcel	$phpExcel	PHPExcel object
		 */
		public function __construct( PHPExcel $phpExcel ) {
			$this->_phpExcel	= $phpExcel;
		}

		/**
		 * Set delimiter
		 *
		 * @param	string	$pValue		Delimiter, defaults to ,
		 * @return PHPExcel_Writer_CSV
		 */
		public function setDelimiter($pValue = ',') {
			$this->_delimiter = $pValue;
			return $this;
		}

		public function save($pFilename = null) {
			// Fetch sheet
			$sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
	
			$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
			PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
			$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
			PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
	
			// Open file
			$fileHandle = fopen($pFilename, 'wb+');
			if ($fileHandle === false) {
				throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing.");
			}
	
			if ($this->_excelCompatibility) {
				fwrite($fileHandle, "\xEF\xBB\xBF");	//	Enforce UTF-8 BOM Header
				$this->setEnclosure('"');				//	Set enclosure to "
				$this->setDelimiter(";");			    //	Set delimiter to a semi-colon
	            $this->setLineEnding("\r\n");
//.........这里部分代码省略.........
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:101,代码来源:export-csv.php


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