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


PHP PHPExcel_Shared_Date::isDateTimeFormatCode方法代码示例

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


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

示例1: TEXTFORMAT

 /**
  *	TEXTFORMAT
  *
  *	@param	mixed	$value	Value to check
  *	@return	boolean
  */
 public static function TEXTFORMAT($value, $format)
 {
     $value = self::flattenSingleValue($value);
     $format = self::flattenSingleValue($format);
     if (is_string($value) && !is_numeric($value) && PHPExcel_Shared_Date::isDateTimeFormatCode($format)) {
         $value = self::DATEVALUE($value);
     }
     return (string) PHPExcel_Style_NumberFormat::toFormattedString($value, $format);
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:15,代码来源:Functions.php

示例2: loadIntoExisting


//.........这里部分代码省略.........
                     //	Cell Range
                     case '80':
                         //	Array
                 }
             }
             $objPHPExcel->getActiveSheet()->getCell($column . $row)->setValueExplicit($cell, $type);
         }
         if (!$this->_readDataOnly && isset($sheet->Objects)) {
             foreach ($sheet->Objects->children('gnm', TRUE) as $key => $comment) {
                 $commentAttributes = $comment->attributes();
                 //	Only comment objects are handled at the moment
                 if ($commentAttributes->Text) {
                     $objPHPExcel->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound)->setAuthor((string) $commentAttributes->Author)->setText($this->_parseRichText((string) $commentAttributes->Text));
                 }
             }
         }
         //			echo '$maxCol=',$maxCol,'; $maxRow=',$maxRow,'<br />';
         //
         foreach ($sheet->Styles->StyleRegion as $styleRegion) {
             $styleAttributes = $styleRegion->attributes();
             if ($styleAttributes['startRow'] <= $maxRow && $styleAttributes['startCol'] <= $maxCol) {
                 $startColumn = PHPExcel_Cell::stringFromColumnIndex((int) $styleAttributes['startCol']);
                 $startRow = $styleAttributes['startRow'] + 1;
                 $endColumn = $styleAttributes['endCol'] > $maxCol ? $maxCol : (int) $styleAttributes['endCol'];
                 $endColumn = PHPExcel_Cell::stringFromColumnIndex($endColumn);
                 $endRow = $styleAttributes['endRow'] > $maxRow ? $maxRow : $styleAttributes['endRow'];
                 $endRow += 1;
                 $cellRange = $startColumn . $startRow . ':' . $endColumn . $endRow;
                 //					echo $cellRange,'<br />';
                 $styleAttributes = $styleRegion->Style->attributes();
                 //					var_dump($styleAttributes);
                 //					echo '<br />';
                 //	We still set the number format mask for date/time values, even if _readDataOnly is true
                 if (!$this->_readDataOnly || PHPExcel_Shared_Date::isDateTimeFormatCode((string) $styleAttributes['Format'])) {
                     $styleArray = array();
                     $styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
                     //	If _readDataOnly is false, we set all formatting information
                     if (!$this->_readDataOnly) {
                         switch ($styleAttributes['HAlign']) {
                             case '1':
                                 $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
                                 break;
                             case '2':
                                 $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
                                 break;
                             case '4':
                                 $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
                                 break;
                             case '8':
                                 $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
                                 break;
                             case '16':
                             case '64':
                                 $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS;
                                 break;
                             case '32':
                                 $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY;
                                 break;
                         }
                         switch ($styleAttributes['VAlign']) {
                             case '1':
                                 $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
                                 break;
                             case '2':
                                 $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
                                 break;
开发者ID:AlexandreSGV,项目名称:siteentec,代码行数:67,代码来源:Gnumeric.php

示例3: write

 /**
  * Map to the appropriate write method acording to the token recieved.
  *
  * @access public
  * @param integer $row	The row of the cell we are writing to
  * @param integer $col	The column of the cell we are writing to
  * @param mixed   $token  What we are writing
  * @param mixed   $format The optional format to apply to the cell
  */
 function write($row, $col, $token, $format = null, $numberFormat = null)
 {
     if ($numberFormat != 'General' && PHPExcel_Shared_Date::isDateTimeFormatCode($numberFormat)) {
         if (is_string($token)) {
             //	Error string
             return $this->writeString($row, $col, $token, $format);
         } elseif (!is_float($token)) {
             //	PHP serialized date/time or date/time object
             return $this->writeNumber($row, $col, PHPExcel_Shared_Date::PHPToExcel($token), $format);
         } else {
             //	Excel serialized date/time
             return $this->writeNumber($row, $col, $token, $format);
         }
     } elseif (preg_match("/^([+-]?)(?=\\d|\\.\\d)\\d*(\\.\\d*)?([Ee]([+-]?\\d+))?\$/", $token)) {
         // Match number
         return $this->writeNumber($row, $col, $token, $format);
     } elseif ($token == '') {
         // Match blank
         return $this->writeBlank($row, $col, $format);
     } else {
         // Default: match string
         return $this->writeString($row, $col, $token, $format);
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:33,代码来源:Worksheet.php

示例4: load


//.........这里部分代码省略.........
                 case self::XLS_Type_RK2:
                     /**
                      * RK
                      *
                      * This record represents a cell that contains an RK value
                      * (encoded integer or floating-point value). If a
                      * floating-point value cannot be encoded to an RK value,
                      * a NUMBER record will be written. This record replaces the
                      * record INTEGER written in BIFF2.
                      *
                      * --	"OpenOffice.org's Documentation of the Microsoft
                      * 		Excel File Format"
                      */
                     $row = ord($this->_data[$spos]) | ord($this->_data[$spos + 1]) << 8;
                     $column = ord($this->_data[$spos + 2]) | ord($this->_data[$spos + 3]) << 8;
                     $rknum = $this->_GetInt4d($this->_data, $spos + 6);
                     $numValue = $this->_GetIEEE754($rknum);
                     /*
                     if ($this->_isDate($spos)) {
                     	list($string, $raw) = $this->_createDate($numValue);
                     } else {
                     	$raw = $numValue;
                     	if (isset($this->_columnsFormat[$column + 1])){
                     		$this->_curformat = $this->_columnsFormat[$column + 1];
                     	}
                     	$string = sprintf($this->_curformat,$numValue*$this->_multiplier);
                     }
                     */
                     // offset 4; size: 2; index to XF record
                     $xfindex = $this->_getInt2d($recordData, 4);
                     // add BIFF8 style information
                     if ($version == self::XLS_BIFF8 && !$this->_readDataOnly) {
                         $sheet->getStyleByColumnAndRow($column, $row + 1)->applyFromArray($this->_xf[$xfindex]);
                         if (PHPExcel_Shared_Date::isDateTimeFormatCode($this->_xf[$xfindex]['numberformat']['code'])) {
                             $numValue = (int) PHPExcel_Shared_Date::ExcelToPHP($numValue);
                         }
                     }
                     //$this->_addcell($row, $column, $string, $raw);
                     //$sheet->setCellValueByColumnAndRow($column, $row + 1, $string);
                     $sheet->setCellValueByColumnAndRow($column, $row + 1, $numValue);
                     break;
                 case self::XLS_Type_LABELSST:
                     /**
                      * LABELSST
                      *
                      * This record represents a cell that contains a string. It
                      * replaces the LABEL record and RSTRING record used in
                      * BIFF2-BIFF5.
                      *
                      * --	"OpenOffice.org's Documentation of the Microsoft
                      * 		Excel File Format"
                      */
                     $row = ord($this->_data[$spos]) | ord($this->_data[$spos + 1]) << 8;
                     $column = ord($this->_data[$spos + 2]) | ord($this->_data[$spos + 3]) << 8;
                     $xfindex = ord($this->_data[$spos + 4]) | ord($this->_data[$spos + 5]) << 8;
                     $index = $this->_GetInt4d($this->_data, $spos + 6);
                     //$this->_addcell($row, $column, $this->_sst[$index]);
                     if ($fmtRuns = $this->_sst[$index]['fmtRuns']) {
                         // then we have rich text
                         $richText = new PHPExcel_RichText($sheet->getCellByColumnAndRow($column, $row + 1));
                         $charPos = 0;
                         for ($i = 0; $i <= count($this->_sst[$index]['fmtRuns']); $i++) {
                             if (isset($fmtRuns[$i])) {
                                 $text = mb_substr($this->_sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos, 'UTF-8');
                                 $charPos = $fmtRuns[$i]['charPos'];
                             } else {
开发者ID:kreativmind,项目名称:storytlr,代码行数:67,代码来源:Excel5.php

示例5: _readFormula

 /**
  * Read FORMULA record
  * This record contains the token array and the result of a
  * formula cell.
  *
  * --	"OpenOffice.org's Documentation of the Microsoft
  * 		Excel File Format"
  */
 private function _readFormula()
 {
     $pos = $this->_pos;
     $length = $this->_GetInt2d($this->_data, $pos + 2);
     $recordData = substr($this->_data, $pos + 4, $length);
     $pos += 4;
     // offset: 0; size: 2; row index
     $row = $this->_GetInt2d($this->_data, $pos);
     // offset: 2; size: 2; col index
     $column = $this->_GetInt2d($this->_data, $pos + 2);
     $columnString = PHPExcel_Cell::stringFromColumnIndex($column);
     // Read cell?
     if (!is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) {
         // offset: 4; size: 2; XF index
         $xfindex = $this->_GetInt2d($this->_data, $pos + 4);
         // offset: 6; size: 8; result of the formula
         if (ord($this->_data[$pos + 6]) == 0 && ord($this->_data[$pos + 12]) == 255 && ord($this->_data[$pos + 13]) == 255) {
             //String formula. Result follows in appended STRING record
             $dataType = PHPExcel_Cell_DataType::TYPE_STRING;
             $soff = $pos + $length;
             $scode = $this->_GetInt2d($this->_data, $soff);
             $slength = $this->_GetInt2d($this->_data, $soff + 2);
             $sdata = substr($this->_data, $soff + 4, $slength);
             if ($this->_version == self::XLS_BIFF8) {
                 $string = $this->_readUnicodeStringLong($sdata);
                 $value = $string['value'];
             } else {
                 $string = $this->_readByteStringLong($sdata);
                 $value = $string['value'];
             }
         } elseif (ord($this->_data[$pos + 6]) == 1 && ord($this->_data[$pos + 12]) == 255 && ord($this->_data[$pos + 13]) == 255) {
             //Boolean formula. Result is in +2; 0=false,1=true
             $dataType = PHPExcel_Cell_DataType::TYPE_BOOL;
             $value = (bool) ord($this->_data[$pos + 8]);
         } elseif (ord($this->_data[$pos + 6]) == 2 && ord($this->_data[$pos + 12]) == 255 && ord($this->_data[$pos + 13]) == 255) {
             //Error formula. Error code is in +2
             $dataType = PHPExcel_Cell_DataType::TYPE_ERROR;
             $value = $this->_mapErrorCode(ord($this->_data[$pos + 8]));
         } elseif (ord($this->_data[$pos + 6]) == 3 && ord($this->_data[$pos + 12]) == 255 && ord($this->_data[$pos + 13]) == 255) {
             //Formula result is a null string
             $dataType = PHPExcel_Cell_DataType::TYPE_NULL;
             $value = '';
         } else {
             // forumla result is a number, first 14 bytes like _NUMBER record
             $dataType = PHPExcel_Cell_DataType::TYPE_NUMERIC;
             $value = $this->_createNumber($pos);
         }
         // add cell style
         if (!$this->_readDataOnly) {
             $this->_phpSheet->getStyle($columnString . ($row + 1))->applyFromArray($this->_xf[$xfindex]);
             if (PHPExcel_Shared_Date::isDateTimeFormatCode($this->_xf[$xfindex]['numberformat']['code'])) {
                 $value = PHPExcel_Shared_Date::ExcelToPHP($value);
             }
         }
         // offset: 14: size: 2; option flags, recalculate always, recalculate on open etc.
         // offset: 16: size: 4; not used
         // offset: 20: size: variable; formula structure
         $formulaStructure = substr($recordData, 20);
         // add cell value
         try {
             if ($this->_version != self::XLS_BIFF8) {
                 throw new Exception('Not BIFF8. Can only read BIFF8 formulas');
             }
             $formula = $this->_getFormulaFromStructure($formulaStructure);
             // get human language
             $this->_phpSheet->getCell($columnString . ($row + 1))->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
         } catch (Exception $e) {
             $this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $value, $dataType);
         }
     }
     // move stream pointer to next record
     $this->_pos += 4 + $length;
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:81,代码来源:Excel5.php

示例6: write

	/**
	* Map to the appropriate write method acording to the token recieved.
	*
	* @access public
	* @param integer $row	The row of the cell we are writing to
	* @param integer $col	The column of the cell we are writing to
	* @param mixed   $token  What we are writing
	* @param mixed   $format The optional format to apply to the cell
	*/
	function write($row, $col, $token, $format = null, $numberFormat = null)
	{
		// Check for a cell reference in A1 notation and substitute row and column
		/*if ($_[0] =~ /^\D/) {
			@_ = $this->_substituteCellref(@_);
		}*/

		if (($numberFormat != 'General') && (PHPExcel_Shared_Date::isDateTimeFormatCode($numberFormat))) {
			if (is_string($token)) {
				//	Error string
				return $this->writeString($row, $col, $token, $format);
			} elseif (!is_float($token)) {
				//	PHP serialized date/time or date/time object
				return $this->writeNumber($row, $col, PHPExcel_Shared_Date::PHPToExcel($token), $format);
			} else {
				//	Excel serialized date/time
				return $this->writeNumber($row, $col, $token, $format);
			}
		} elseif (preg_match("/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/", $token)) {
			// Match number
			return $this->writeNumber($row, $col, $token, $format);
		} elseif (preg_match("/^[fh]tt?p:\/\//", $token)) {
			// Match http or ftp URL
			return $this->writeUrl($row, $col, $token, '', $format);
		} elseif (preg_match("/^mailto:/", $token)) {
			// Match mailto:
			return $this->writeUrl($row, $col, $token, '', $format);
		} elseif (preg_match("/^(?:in|ex)ternal:/", $token)) {
			// Match internal or external sheet link
			return $this->writeUrl($row, $col, $token, '', $format);
		} elseif (preg_match("/^=/", $token)) {
			// Match formula
			return $this->writeFormula($row, $col, $token, $format);
		} elseif (preg_match("/^@/", $token)) {
			// Match formula
			return $this->writeFormula($row, $col, $token, $format);
		} elseif ($token == '') {
			// Match blank
			return $this->writeBlank($row, $col, $format);
		} else {
			// Default: match string
			return $this->writeString($row, $col, $token, $format);
		}
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:53,代码来源:Worksheet.php


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