Finish namespacing the Readers

This commit is contained in:
MarkBaker 2015-06-03 00:10:08 +01:00
parent 0d956534eb
commit f1e8ec1f4d
11 changed files with 515 additions and 309 deletions

View File

@ -78,7 +78,7 @@ class CSV extends BaseReader implements IReader
/**
* Create a new CSV
* Create a new CSV Reader instance
*/
public function __construct()
{

View File

@ -44,7 +44,7 @@ class Excel2003XML extends BaseReader implements IReader
protected $charSet = 'UTF-8';
/**
* Create a new Excel2003XML
* Create a new Excel2003XML Reader instance
*/
public function __construct()
{

File diff suppressed because it is too large Load Diff

View File

@ -405,7 +405,7 @@ class Excel5 extends BaseReader implements IReader
private $md5Ctxt = null;
/**
* Create a new Excel5 instance
* Create a new Excel5 Reader instance
*/
public function __construct()
{

View File

@ -91,16 +91,16 @@ class HTML extends BaseReader implements IReader
'font' => array(
'underline' => true,
'color' => array(
'argb' => PHPExcel_Style_Color::COLOR_BLUE,
'argb' => \PHPExcel\Style\Color::COLOR_BLUE,
),
),
), // Blue underlined
'hr' => array(
'borders' => array(
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'style' => \PHPExcel\Style\Border::BORDER_THIN,
'color' => array(
PHPExcel_Style_Color::COLOR_BLACK,
\PHPExcel\Style\Color::COLOR_BLACK,
),
),
),
@ -110,11 +110,11 @@ class HTML extends BaseReader implements IReader
protected $rowspan = array();
/**
* Create a new PHPExcel_Reader_HTML
* Create a new HTML Reader instance
*/
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->readFilter = new DefaultReadFilter();
}
/**
@ -139,7 +139,7 @@ class HTML extends BaseReader implements IReader
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function load($pFilename)
{
@ -421,7 +421,7 @@ class HTML extends BaseReader implements IReader
++$columnTo;
}
$range = $column . $row . ':' . $columnTo . ($row + $attributeArray['rowspan'] - 1);
foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) {
foreach (\PHPExcel\Cell::extractAllCellReferencesInRange($range) as $value) {
$this->rowspan[$value] = true;
}
$sheet->mergeCells($range);
@ -429,7 +429,7 @@ class HTML extends BaseReader implements IReader
} elseif (isset($attributeArray['rowspan'])) {
//create merging rowspan
$range = $column . $row . ':' . $column . ($row + $attributeArray['rowspan'] - 1);
foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) {
foreach (\PHPExcel\Cell::extractAllCellReferencesInRange($range) as $value) {
$this->rowspan[$value] = true;
}
$sheet->mergeCells($range);
@ -464,7 +464,7 @@ class HTML extends BaseReader implements IReader
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
@ -472,7 +472,7 @@ class HTML extends BaseReader implements IReader
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
throw new Exception($pFilename . " is an Invalid HTML file.");
}
// Close after validating
fclose($this->fileHandle);
@ -488,7 +488,7 @@ class HTML extends BaseReader implements IReader
// Reload the HTML file into the DOM object
$loaded = $dom->loadHTML($this->securityScanFile($pFilename));
if ($loaded === false) {
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
throw new Exception('Failed to load ', $pFilename, ' as a DOM Document');
}
// Discard white space
@ -517,7 +517,7 @@ class HTML extends BaseReader implements IReader
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_HTML
* @return HTML
*/
public function setSheetIndex($pValue = 0)
{
@ -530,13 +530,13 @@ class HTML extends BaseReader implements IReader
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $xml
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function securityScan($xml)
{
$pattern = '/\\0?' . implode('\\0?', str_split('<!ENTITY')) . '\\0?/';
if (preg_match($pattern, $xml)) {
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
throw new Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
}
return $xml;
}

View File

@ -37,32 +37,32 @@ class OOCalc extends BaseReader implements IReader
private $styles = array();
/**
* Create a new PHPExcel_Reader_OOCalc
* Create a new OOCalc Reader instance
*/
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->readFilter = new DefaultReadFilter();
}
/**
* Can the current PHPExcel_Reader_IReader read the file?
* Can the current IReader read the file?
*
* @param string $pFilename
* @return boolean
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$zipClass = PHPExcel_Settings::getZipClass();
$zipClass = \PHPExcel\Settings::getZipClass();
// Check if zip class exists
// if (!class_exists($zipClass, false)) {
// throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled");
// throw new Exception($zipClass . " library is not enabled");
// }
$mimeType = 'UNKNOWN';
@ -74,7 +74,11 @@ class OOCalc extends BaseReader implements IReader
if ($stat && ($stat['size'] <= 255)) {
$mimeType = $zip->getFromName($stat['name']);
} elseif ($stat = $zip->statName('META-INF/manifest.xml')) {
$xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string(
$this->securityScan($zip->getFromName('META-INF/manifest.xml')),
'SimpleXMLElement',
\PHPExcel\Settings::getLibXmlLoaderOptions()
);
$namespacesContent = $xml->getNamespaces(true);
if (isset($namespacesContent['manifest'])) {
$manifest = $xml->children($namespacesContent['manifest']);
@ -101,26 +105,30 @@ class OOCalc extends BaseReader implements IReader
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$zipClass = PHPExcel_Settings::getZipClass();
$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.");
throw new Exception("Could not open " . $pFilename . " for reading! Error opening file.");
}
$worksheetNames = array();
$xml = new XMLReader();
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$res = $xml->xml(
$this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'),
null,
\PHPExcel\Settings::getLibXmlLoaderOptions()
);
$xml->setParserProperty(2, true);
// Step into the first level of content of the XML
@ -153,26 +161,30 @@ class OOCalc extends BaseReader implements IReader
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetInfo = array();
$zipClass = PHPExcel_Settings::getZipClass();
$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.");
throw new Exception("Could not open " . $pFilename . " for reading! Error opening file.");
}
$xml = new XMLReader();
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$res = $xml->xml(
$this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'),
null,
\PHPExcel\Settings::getLibXmlLoaderOptions()
);
$xml->setParserProperty(2, true);
// Step into the first level of content of the XML
@ -230,7 +242,7 @@ class OOCalc extends BaseReader implements IReader
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$tmpInfo['lastColumnLetter'] = \PHPExcel\Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$worksheetInfo[] = $tmpInfo;
}
}
@ -264,7 +276,7 @@ class OOCalc extends BaseReader implements IReader
// }
// }
//
// $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
// $tmpInfo['lastColumnLetter'] = \PHPExcel\Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
// $tmpInfo['totalColumns'] = $tmpInfo['lastColumnIndex'] + 1;
//
// }
@ -278,8 +290,8 @@ class OOCalc extends BaseReader implements IReader
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @return Spreadsheet
* @throws Exception
*/
public function load($pFilename)
{
@ -306,29 +318,33 @@ class OOCalc extends BaseReader implements IReader
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @param Spreadsheet $objPHPExcel
* @return Spreadsheet
* @throws 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.");
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC');
$zipClass = PHPExcel_Settings::getZipClass();
$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.");
throw new Exception("Could not open " . $pFilename . " for reading! Error opening file.");
}
// echo '<h1>Meta Information</h1>';
$xml = simplexml_load_string($this->securityScan($zip->getFromName("meta.xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string(
$this->securityScan($zip->getFromName("meta.xml")),
'SimpleXMLElement',
\PHPExcel\Settings::getLibXmlLoaderOptions()
);
$namespacesMeta = $xml->getNamespaces(true);
// echo '<pre>';
// print_r($namespacesMeta);
@ -414,7 +430,11 @@ class OOCalc extends BaseReader implements IReader
// echo '<h1>Workbook Content</h1>';
$xml = simplexml_load_string($this->securityScan($zip->getFromName("content.xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string(
$this->securityScan($zip->getFromName("content.xml")),
'SimpleXMLElement',
\PHPExcel\Settings::getLibXmlLoaderOptions()
);
$namespacesContent = $xml->getNamespaces(true);
// echo '<pre>';
// print_r($namespacesContent);
@ -533,7 +553,7 @@ class OOCalc extends BaseReader implements IReader
// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />';
switch ($cellDataOfficeAttributes['value-type']) {
case 'string':
$type = PHPExcel_Cell_DataType::TYPE_STRING;
$type = \PHPExcel\Cell\DataType::TYPE_STRING;
$dataValue = $allCellDataText;
if (isset($dataValue->a)) {
$dataValue = $dataValue->a;
@ -542,27 +562,27 @@ class OOCalc extends BaseReader implements IReader
}
break;
case 'boolean':
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
$type = \PHPExcel\Cell\DataType::TYPE_BOOL;
$dataValue = ($allCellDataText == 'TRUE') ? true : false;
break;
case 'percentage':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$type = \PHPExcel\Cell\DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue;
}
$formatting = PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00;
$formatting = \PHPExcel\Style\NumberFormat::FORMAT_PERCENTAGE_00;
break;
case 'currency':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$type = \PHPExcel\Cell\DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
$dataValue = (integer) $dataValue;
}
$formatting = PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
$formatting = \PHPExcel\Style\NumberFormat::FORMAT_CURRENCY_USD_SIMPLE;
break;
case 'float':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$type = \PHPExcel\Cell\DataType::TYPE_NUMERIC;
$dataValue = (float) $cellDataOfficeAttributes['value'];
if (floor($dataValue) == $dataValue) {
if ($dataValue == (integer) $dataValue) {
@ -573,21 +593,21 @@ class OOCalc extends BaseReader implements IReader
}
break;
case 'date':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$type = \PHPExcel\Cell\DataType::TYPE_NUMERIC;
$dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
$dateObj->setTimeZone($timezoneObj);
list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s'));
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second);
$dataValue = \PHPExcel\Shared\Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second);
if ($dataValue != floor($dataValue)) {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
$formatting = \PHPExcel\Style\NumberFormat::FORMAT_DATE_XLSX15.' '.\PHPExcel\Style\NumberFormat::FORMAT_DATE_TIME4;
} else {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15;
$formatting = \PHPExcel\Style\NumberFormat::FORMAT_DATE_XLSX15;
}
break;
case 'time':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':', sscanf($cellDataOfficeAttributes['time-value'], 'PT%dH%dM%dS'))));
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
$type = \PHPExcel\Cell\DataType::TYPE_NUMERIC;
$dataValue = \PHPExcel\Shared\Date::PHPToExcel(strtotime('01-01-1970 '.implode(':', sscanf($cellDataOfficeAttributes['time-value'], 'PT%dH%dM%dS'))));
$formatting = \PHPExcel\Style\NumberFormat::FORMAT_DATE_TIME4;
break;
}
// echo 'Data value is '.$dataValue.'<br />';
@ -595,12 +615,12 @@ class OOCalc extends BaseReader implements IReader
// echo 'Hyperlink is '.$hyperlink.'<br />';
// }
} else {
$type = PHPExcel_Cell_DataType::TYPE_NULL;
$type = \PHPExcel\Cell\DataType::TYPE_NULL;
$dataValue = null;
}
if ($hasCalculatedValue) {
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
$type = \PHPExcel\Cell\DataType::TYPE_FORMULA;
// echo 'Formula: ', $cellDataFormula, PHP_EOL;
$cellDataFormula = substr($cellDataFormula, strpos($cellDataFormula, ':=')+1);
$temp = explode('"', $cellDataFormula);
@ -612,7 +632,7 @@ class OOCalc extends BaseReader implements IReader
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui', '$1!$2', $value); // Cell reference in another sheet
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); // Cell range reference
$value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); // Simple cell reference
$value = PHPExcel_Calculation::translateSeparator(';', ',', $value, $inBraces);
$value = \PHPExcel\Calculation::translateSeparator(';', ',', $value, $inBraces);
}
}
unset($value);
@ -627,7 +647,7 @@ class OOCalc extends BaseReader implements IReader
if ($i > 0) {
++$columnID;
}
if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
if ($type !== \PHPExcel\Cell\DataType::TYPE_NULL) {
for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
$rID = $rowID + $rowAdjust;
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue), $type);
@ -638,7 +658,7 @@ class OOCalc extends BaseReader implements IReader
if ($formatting !== null) {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode($formatting);
} else {
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rID)->getNumberFormat()->setFormatCode(\PHPExcel\Style\NumberFormat::FORMAT_GENERAL);
}
if ($hyperlink !== null) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->getHyperlink()->setUrl($hyperlink);
@ -650,10 +670,10 @@ class OOCalc extends BaseReader implements IReader
// Merged cells
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->readDataOnly)) {
if (($type !== \PHPExcel\Cell\DataType::TYPE_NULL) || (!$this->readDataOnly)) {
$columnTo = $columnID;
if (isset($cellDataTableAttributes['number-columns-spanned'])) {
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
$columnTo = \PHPExcel\Cell::stringFromColumnIndex(\PHPExcel\Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
}
$rowTo = $rowID;
if (isset($cellDataTableAttributes['number-rows-spanned'])) {
@ -680,7 +700,7 @@ class OOCalc extends BaseReader implements IReader
private function parseRichText($is = '')
{
$value = new PHPExcel_RichText();
$value = new \PHPExcel\RichText();
$value->createText($is);

View File

@ -58,11 +58,11 @@ class SYLK extends BaseReader implements IReader
private $format = 0;
/**
* Create a new PHPExcel_Reader_SYLK
* Create a new SYLK Reader instance
*/
public function __construct()
{
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->readFilter = new DefaultReadFilter();
}
/**
@ -115,7 +115,7 @@ class SYLK extends BaseReader implements IReader
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws PHPExcel_Reader_Exception
* @throws Exception
*/
public function listWorksheetInfo($pFilename)
{
@ -123,7 +123,7 @@ class SYLK extends BaseReader implements IReader
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->fileHandle;
rewind($fileHandle);
@ -144,7 +144,7 @@ class SYLK extends BaseReader implements IReader
$columnIndex = 0;
// convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
$rowData = \PHPExcel\Shared\String::SYLKtoUTF8($rowData);
// explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;)
@ -171,7 +171,7 @@ class SYLK extends BaseReader implements IReader
}
}
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['lastColumnLetter'] = \PHPExcel\Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
// Close file
@ -184,13 +184,13 @@ class SYLK extends BaseReader implements IReader
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @return Spreadsheet
* @throws Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
$objPHPExcel = new Spreadsheet();
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
@ -200,22 +200,22 @@ class SYLK extends BaseReader implements IReader
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
* @param Spreadsheet $objPHPExcel
* @return Spreadsheet
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
public function loadIntoExisting($pFilename, Spreadsheet $objPHPExcel)
{
// Open file
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$fileHandle = $this->fileHandle;
rewind($fileHandle);
// Create new PHPExcel
// Create new Worksheets
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet();
}
@ -231,7 +231,7 @@ class SYLK extends BaseReader implements IReader
// loop through one row (line) at a time in the file
while (($rowData = fgets($fileHandle)) !== false) {
// convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
$rowData = \PHPExcel\Shared\String::SYLKtoUTF8($rowData);
// explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;)
@ -264,16 +264,16 @@ class SYLK extends BaseReader implements IReader
$formatArray['font']['bold'] = true;
break;
case 'T':
$formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
$formatArray['borders']['top']['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
case 'B':
$formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
$formatArray['borders']['bottom']['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
case 'L':
$formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
$formatArray['borders']['left']['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
case 'R':
$formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
$formatArray['borders']['right']['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
}
}
@ -332,7 +332,7 @@ class SYLK extends BaseReader implements IReader
if ($columnReference{0} == '[') {
$columnReference = $column + trim($columnReference, '[]');
}
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$A1CellReference = \PHPExcel\Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0]));
}
@ -345,13 +345,13 @@ class SYLK extends BaseReader implements IReader
break;
}
}
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$cellData = PHPExcel_Calculation::unwrapResult($cellData);
$columnLetter = \PHPExcel\Cell::stringFromColumnIndex($column-1);
$cellData = \PHPExcel\Calculation::unwrapResult($cellData);
// Set cell value
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
if ($hasCalculatedValue) {
$cellData = PHPExcel_Calculation::unwrapResult($cellData);
$cellData = \PHPExcel\Calculation::unwrapResult($cellData);
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
}
// Read cell formatting
@ -385,16 +385,16 @@ class SYLK extends BaseReader implements IReader
$styleData['font']['bold'] = true;
break;
case 'T':
$styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
$styleData['borders']['top']['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
case 'B':
$styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
$styleData['borders']['bottom']['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
case 'L':
$styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
$styleData['borders']['left']['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
case 'R':
$styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
$styleData['borders']['right']['style'] = \PHPExcel\Style\Border::BORDER_THIN;
break;
}
}
@ -402,22 +402,22 @@ class SYLK extends BaseReader implements IReader
}
}
if (($formatStyle > '') && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$columnLetter = \PHPExcel\Cell::stringFromColumnIndex($column-1);
if (isset($this->formats[$formatStyle])) {
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->formats[$formatStyle]);
}
}
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$columnLetter = \PHPExcel\Cell::stringFromColumnIndex($column-1);
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
}
if ($columnWidth > '') {
if ($startCol == $endCol) {
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
$startCol = \PHPExcel\Cell::stringFromColumnIndex($startCol-1);
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
} else {
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
$startCol = \PHPExcel\Cell::stringFromColumnIndex($startCol-1);
$endCol = \PHPExcel\Cell::stringFromColumnIndex($endCol-1);
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
do {
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
@ -461,7 +461,7 @@ class SYLK extends BaseReader implements IReader
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_SYLK
* @return SYLK
*/
public function setSheetIndex($pValue = 0)
{

View File

@ -1,5 +1,7 @@
<?php
namespace PHPExcel\Writer\PDF;
/**
* PHPExcel_Writer_PDF_Core
*
@ -25,7 +27,7 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
abstract class Core extends \PHPExcel\Writer\HTML
{
/**
* Temporary storage directory
@ -204,11 +206,11 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
);
/**
* Create a new PHPExcel_Writer_PDF
* Create a new PDF Writer instance
*
* @param PHPExcel $phpExcel PHPExcel object
* @param Spreadsheet $phpExcel Spreadsheet object
*/
public function __construct(PHPExcel $phpExcel)
public function __construct(Spreadsheet $phpExcel)
{
parent::__construct($phpExcel);
$this->setUseInlineCss(true);
@ -312,7 +314,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
}
/**
* Save PHPExcel to PDF file, pre-save
* Save Spreadsheet to PDF file, pre-save
*
* @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception

View File

@ -1,11 +1,13 @@
<?php
namespace PHPExcel\Writer\PDF;
/** Require DomPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
$pdfRendererClassFile = \PHPExcel\Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
if (file_exists($pdfRendererClassFile)) {
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
throw new \PHPExcel\Writer\Exception('Unable to load PDF Rendering library');
}
/**
@ -33,20 +35,20 @@ if (file_exists($pdfRendererClassFile)) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
class DomPDF extends Core implements \PHPExcel\Writer\IWriter
{
/**
* Create a new PHPExcel_Writer_PDF
* Create a new DomPDF Writer instance
*
* @param PHPExcel $phpExcel PHPExcel object
* @param Spreadsheet $phpExcel Spreadsheet object
*/
public function __construct(PHPExcel $phpExcel)
public function __construct(Spreadsheet $phpExcel)
{
parent::__construct($phpExcel);
}
/**
* Save PHPExcel to file
* Save Spreadsheet to file
*
* @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception

View File

@ -1,11 +1,13 @@
<?php
namespace PHPExcel\Writer\PDF;
/** Require mPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/mpdf.php';
$pdfRendererClassFile = \PHPExcel\Settings::getPdfRendererPath() . '/mpdf.php';
if (file_exists($pdfRendererClassFile)) {
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
throw new \PHPExcel\Writer\Exception('Unable to load PDF Rendering library');
}
/**
@ -33,20 +35,20 @@ if (file_exists($pdfRendererClassFile)) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
class mPDF extends Core implements \PHPExcel\Writer\IWriter
{
/**
* Create a new PHPExcel_Writer_PDF
* Create a mPDF Writer instance
*
* @param PHPExcel $phpExcel PHPExcel object
* @param Spreadsheet $phpExcel Spreadsheet object
*/
public function __construct(PHPExcel $phpExcel)
public function __construct(Spreadsheet $phpExcel)
{
parent::__construct($phpExcel);
}
/**
* Save PHPExcel to file
* Save Spreadsheet to file
*
* @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception

View File

@ -1,12 +1,14 @@
<?php
namespace PHPExcel\Writer\PDF;
/** Require tcPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/tcpdf.php';
$pdfRendererClassFile = \PHPExcel\Settings::getPdfRendererPath() . '/tcpdf.php';
if (file_exists($pdfRendererClassFile)) {
$k_path_url = PHPExcel_Settings::getPdfRendererPath();
$k_path_url = \PHPExcel\Settings::getPdfRendererPath();
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
throw new \PHPExcel\Writer\Exception('Unable to load PDF Rendering library');
}
/**
@ -34,20 +36,20 @@ if (file_exists($pdfRendererClassFile)) {
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
class tcPDF extends Core implements \PHPExcel\Writer\IWriter
{
/**
* Create a new PHPExcel_Writer_PDF
* Create a new tcPDF Writer instance
*
* @param PHPExcel $phpExcel PHPExcel object
* @param Spreadsheet $phpExcel Spreadsheet object
*/
public function __construct(PHPExcel $phpExcel)
public function __construct(Spreadsheet $phpExcel)
{
parent::__construct($phpExcel);
}
/**
* Save PHPExcel to file
* Save Spreadsheet to file
*
* @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception