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


PHP PHPExcel_Settings::getLibXmlLoaderOptions方法代码示例

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


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

示例1: loadIntoExisting

 /**
  * Loads PHPExcel from file into PHPExcel instance
  *
  * @param 	string 		$pFilename
  * @param	PHPExcel	$objPHPExcel
  * @return 	PHPExcel
  * @throws 	PHPExcel_Reader_Exception
  */
 public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
 {
     // Check if file exists
     if (!file_exists($pFilename)) {
         throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
     }
     $timezoneObj = new DateTimeZone('Europe/London');
     $GMT = new DateTimeZone('UTC');
     $zipClass = PHPExcel_Settings::getZipClass();
     $zip = new $zipClass();
     if (!$zip->open($pFilename)) {
         throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! Error opening file.");
     }
     //		echo '<h1>Meta Information</h1>';
     $xml = simplexml_load_string($zip->getFromName("meta.xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
     $namespacesMeta = $xml->getNamespaces(true);
     //		echo '<pre>';
     //		print_r($namespacesMeta);
     //		echo '</pre><hr />';
     $docProps = $objPHPExcel->getProperties();
     $officeProperty = $xml->children($namespacesMeta['office']);
     foreach ($officeProperty as $officePropertyData) {
         $officePropertyDC = array();
         if (isset($namespacesMeta['dc'])) {
             $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
         }
         foreach ($officePropertyDC as $propertyName => $propertyValue) {
             $propertyValue = (string) $propertyValue;
             switch ($propertyName) {
                 case 'title':
                     $docProps->setTitle($propertyValue);
                     break;
                 case 'subject':
                     $docProps->setSubject($propertyValue);
                     break;
                 case 'creator':
                     $docProps->setCreator($propertyValue);
                     $docProps->setLastModifiedBy($propertyValue);
                     break;
                 case 'date':
                     $creationDate = strtotime($propertyValue);
                     $docProps->setCreated($creationDate);
                     $docProps->setModified($creationDate);
                     break;
                 case 'description':
                     $docProps->setDescription($propertyValue);
                     break;
             }
         }
         $officePropertyMeta = array();
         if (isset($namespacesMeta['dc'])) {
             $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
         }
         foreach ($officePropertyMeta as $propertyName => $propertyValue) {
             $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']);
             $propertyValue = (string) $propertyValue;
             switch ($propertyName) {
                 case 'initial-creator':
                     $docProps->setCreator($propertyValue);
                     break;
                 case 'keyword':
                     $docProps->setKeywords($propertyValue);
                     break;
                 case 'creation-date':
                     $creationDate = strtotime($propertyValue);
                     $docProps->setCreated($creationDate);
                     break;
                 case 'user-defined':
                     $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
                     foreach ($propertyValueAttributes as $key => $value) {
                         if ($key == 'name') {
                             $propertyValueName = (string) $value;
                         } elseif ($key == 'value-type') {
                             switch ($value) {
                                 case 'date':
                                     $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'date');
                                     $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
                                     break;
                                 case 'boolean':
                                     $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'bool');
                                     $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
                                     break;
                                 case 'float':
                                     $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue, 'r4');
                                     $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
                                     break;
                                 default:
                                     $propertyValueType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
                             }
                         }
                     }
                     $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType);
//.........这里部分代码省略.........
开发者ID:arjunkumar786,项目名称:faces,代码行数:101,代码来源:OOCalc.php

示例2: loadIntoExisting

 /**
  * Loads PHPExcel from file into PHPExcel instance
  *
  * @param 	string 		$pFilename
  * @param	PHPExcel	$objPHPExcel
  * @return 	PHPExcel
  * @throws 	PHPExcel_Reader_Exception
  */
 public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
 {
     $fromFormats = array('\\-', '\\ ');
     $toFormats = array('-', ' ');
     $underlineStyles = array(PHPExcel_Style_Font::UNDERLINE_NONE, PHPExcel_Style_Font::UNDERLINE_DOUBLE, PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING, PHPExcel_Style_Font::UNDERLINE_SINGLE, PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING);
     $verticalAlignmentStyles = array(PHPExcel_Style_Alignment::VERTICAL_BOTTOM, PHPExcel_Style_Alignment::VERTICAL_TOP, PHPExcel_Style_Alignment::VERTICAL_CENTER, PHPExcel_Style_Alignment::VERTICAL_JUSTIFY);
     $horizontalAlignmentStyles = array(PHPExcel_Style_Alignment::HORIZONTAL_GENERAL, PHPExcel_Style_Alignment::HORIZONTAL_LEFT, PHPExcel_Style_Alignment::HORIZONTAL_RIGHT, PHPExcel_Style_Alignment::HORIZONTAL_CENTER, PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS, PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY);
     $timezoneObj = new DateTimeZone('Europe/London');
     $GMT = new DateTimeZone('UTC');
     // Check if file exists
     if (!file_exists($pFilename)) {
         throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
     }
     if (!$this->canRead($pFilename)) {
         throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
     }
     $xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
     $namespaces = $xml->getNamespaces(true);
     $docProps = $objPHPExcel->getProperties();
     if (isset($xml->DocumentProperties[0])) {
         foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
             switch ($propertyName) {
                 case 'Title':
                     $docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
                 case 'Subject':
                     $docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
                 case 'Author':
                     $docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
                 case 'Created':
                     $creationDate = strtotime($propertyValue);
                     $docProps->setCreated($creationDate);
                     break;
                 case 'LastAuthor':
                     $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
                 case 'LastSaved':
                     $lastSaveDate = strtotime($propertyValue);
                     $docProps->setModified($lastSaveDate);
                     break;
                 case 'Company':
                     $docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
                 case 'Category':
                     $docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
                 case 'Manager':
                     $docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
                 case 'Keywords':
                     $docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
                 case 'Description':
                     $docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet));
                     break;
             }
         }
     }
     if (isset($xml->CustomDocumentProperties)) {
         foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
             $propertyAttributes = $propertyValue->attributes($namespaces['dt']);
             $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/', 'PHPExcel_Reader_Excel2003XML::_hex2str', $propertyName);
             $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN;
             switch ((string) $propertyAttributes) {
                 case 'string':
                     $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
                     $propertyValue = trim($propertyValue);
                     break;
                 case 'boolean':
                     $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
                     $propertyValue = (bool) $propertyValue;
                     break;
                 case 'integer':
                     $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER;
                     $propertyValue = intval($propertyValue);
                     break;
                 case 'float':
                     $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
                     $propertyValue = floatval($propertyValue);
                     break;
                 case 'dateTime.tz':
                     $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
                     $propertyValue = strtotime(trim($propertyValue));
                     break;
             }
             $docProps->setCustomProperty($propertyName, $propertyValue, $propertyType);
         }
     }
     foreach ($xml->Styles[0] as $style) {
         $style_ss = $style->attributes($namespaces['ss']);
//.........这里部分代码省略.........
开发者ID:ahsanmage,项目名称:vr,代码行数:101,代码来源:Excel2003XML.php

示例3: loadIntoExisting

 /**
  * Loads PHPExcel from file into PHPExcel instance
  *
  * @param 	string 		$pFilename
  * @param	PHPExcel	$objPHPExcel
  * @return 	PHPExcel
  * @throws 	PHPExcel_Reader_Exception
  */
 public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
 {
     // Open file to validate
     $this->_openFile($pFilename);
     if (!$this->_isValidFormat()) {
         fclose($this->_fileHandle);
         throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
     }
     //	Close after validating
     fclose($this->_fileHandle);
     // Create new PHPExcel
     while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
         $objPHPExcel->createSheet();
     }
     $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
     //	Create a new DOM object
     $dom = new DOMDocument();
     //	Reload the HTML file into the DOM object
     $loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions());
     if ($loaded === FALSE) {
         throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
     }
     //	Discard white space
     $dom->preserveWhiteSpace = false;
     $row = 0;
     $column = 'A';
     $content = '';
     $this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
     //		echo '<hr />';
     //		var_dump($this->_dataArray);
     // Return
     return $objPHPExcel;
 }
开发者ID:fgaudenzi,项目名称:webERP-bootstrap,代码行数:41,代码来源:HTML.php

示例4: _readRibbon

 private function _readRibbon($excel, $customUITarget, $zip)
 {
     $baseDir = dirname($customUITarget);
     $nameCustomUI = basename($customUITarget);
     // get the xml file (ribbon)
     $localRibbon = $this->_getFromZipArchive($zip, $customUITarget);
     $customUIImagesNames = array();
     $customUIImagesBinaries = array();
     // something like customUI/_rels/customUI.xml.rels
     $pathRels = $baseDir . '/_rels/' . $nameCustomUI . '.rels';
     $dataRels = $this->_getFromZipArchive($zip, $pathRels);
     if ($dataRels) {
         // exists and not empty if the ribbon have some pictures (other than internal MSO)
         $UIRels = simplexml_load_string($dataRels, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
         if ($UIRels) {
             // we need to save id and target to avoid parsing customUI.xml and "guess" if it's a pseudo callback who load the image
             foreach ($UIRels->Relationship as $ele) {
                 if ($ele["Type"] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') {
                     // an image ?
                     $customUIImagesNames[(string) $ele['Id']] = (string) $ele['Target'];
                     $customUIImagesBinaries[(string) $ele['Target']] = $this->_getFromZipArchive($zip, $baseDir . '/' . (string) $ele['Target']);
                 }
             }
         }
     }
     if ($localRibbon) {
         $excel->setRibbonXMLData($customUITarget, $localRibbon);
         if (count($customUIImagesNames) > 0 && count($customUIImagesBinaries) > 0) {
             $excel->setRibbonBinObjects($customUIImagesNames, $customUIImagesBinaries);
         } else {
             $excel->setRibbonBinObjects(NULL);
         }
     } else {
         $excel->setRibbonXMLData(NULL);
         $excel->setRibbonBinObjects(NULL);
     }
 }
开发者ID:Sect0R,项目名称:profishop,代码行数:37,代码来源:Excel2007.php

示例5: loadIntoExisting

 /**
  * Loads PHPExcel from file into PHPExcel instance
  *
  * @param     string         $pFilename
  * @param    PHPExcel    $objPHPExcel
  * @return     PHPExcel
  * @throws     PHPExcel_Reader_Exception
  */
 public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
 {
     // Check if file exists
     if (!file_exists($pFilename)) {
         throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
     }
     $timezoneObj = new DateTimeZone('Europe/London');
     $GMT = new DateTimeZone('UTC');
     $gFileData = $this->gzfileGetContents($pFilename);
     //        echo '<pre>';
     //        echo htmlentities($gFileData,ENT_QUOTES,'UTF-8');
     //        echo '</pre><hr />';
     //
     $xml = simplexml_load_string($this->securityScan($gFileData), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
     $namespacesMeta = $xml->getNamespaces(true);
     //        var_dump($namespacesMeta);
     //
     $gnmXML = $xml->children($namespacesMeta['gnm']);
     $docProps = $objPHPExcel->getProperties();
     //    Document Properties are held differently, depending on the version of Gnumeric
     if (isset($namespacesMeta['office'])) {
         $officeXML = $xml->children($namespacesMeta['office']);
         $officeDocXML = $officeXML->{'document-meta'};
         $officeDocMetaXML = $officeDocXML->meta;
         foreach ($officeDocMetaXML as $officePropertyData) {
             $officePropertyDC = array();
             if (isset($namespacesMeta['dc'])) {
                 $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
             }
             foreach ($officePropertyDC as $propertyName => $propertyValue) {
                 $propertyValue = (string) $propertyValue;
                 switch ($propertyName) {
                     case 'title':
                         $docProps->setTitle(trim($propertyValue));
                         break;
                     case 'subject':
                         $docProps->setSubject(trim($propertyValue));
                         break;
                     case 'creator':
                         $docProps->setCreator(trim($propertyValue));
                         $docProps->setLastModifiedBy(trim($propertyValue));
                         break;
                     case 'date':
                         $creationDate = strtotime(trim($propertyValue));
                         $docProps->setCreated($creationDate);
                         $docProps->setModified($creationDate);
                         break;
                     case 'description':
                         $docProps->setDescription(trim($propertyValue));
                         break;
                 }
             }
             $officePropertyMeta = array();
             if (isset($namespacesMeta['meta'])) {
                 $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
             }
             foreach ($officePropertyMeta as $propertyName => $propertyValue) {
                 $attributes = $propertyValue->attributes($namespacesMeta['meta']);
                 $propertyValue = (string) $propertyValue;
                 switch ($propertyName) {
                     case 'keyword':
                         $docProps->setKeywords(trim($propertyValue));
                         break;
                     case 'initial-creator':
                         $docProps->setCreator(trim($propertyValue));
                         $docProps->setLastModifiedBy(trim($propertyValue));
                         break;
                     case 'creation-date':
                         $creationDate = strtotime(trim($propertyValue));
                         $docProps->setCreated($creationDate);
                         $docProps->setModified($creationDate);
                         break;
                     case 'user-defined':
                         list(, $attrName) = explode(':', $attributes['name']);
                         switch ($attrName) {
                             case 'publisher':
                                 $docProps->setCompany(trim($propertyValue));
                                 break;
                             case 'category':
                                 $docProps->setCategory(trim($propertyValue));
                                 break;
                             case 'manager':
                                 $docProps->setManager(trim($propertyValue));
                                 break;
                         }
                         break;
                 }
             }
         }
     } elseif (isset($gnmXML->Summary)) {
         foreach ($gnmXML->Summary->Item as $summaryItem) {
             $propertyName = $summaryItem->name;
//.........这里部分代码省略.........
开发者ID:pzhu2004,项目名称:moodle,代码行数:101,代码来源:Gnumeric.php


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