php-cs run: fixed code style for new/changed files
This commit is contained in:
parent
a0321fd6fd
commit
9785f926c1
|
@ -107,6 +107,7 @@ class Ods extends BaseReader implements IReader
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function listWorksheetNames($pFilename)
|
public function listWorksheetNames($pFilename)
|
||||||
|
@ -163,6 +164,7 @@ class Ods extends BaseReader implements IReader
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function listWorksheetInfo($pFilename)
|
public function listWorksheetInfo($pFilename)
|
||||||
|
@ -173,7 +175,7 @@ class Ods extends BaseReader implements IReader
|
||||||
|
|
||||||
$zipClass = \PhpOffice\PhpSpreadsheet\Settings::getZipClass();
|
$zipClass = \PhpOffice\PhpSpreadsheet\Settings::getZipClass();
|
||||||
|
|
||||||
/** @var \ZipArchive $zip */
|
/** @var \ZipArchive $zip */
|
||||||
$zip = new $zipClass();
|
$zip = new $zipClass();
|
||||||
if (!$zip->open($pFilename)) {
|
if (!$zip->open($pFilename)) {
|
||||||
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
throw new Exception('Could not open ' . $pFilename . ' for reading! Error opening file.');
|
||||||
|
@ -407,25 +409,23 @@ class Ods extends BaseReader implements IReader
|
||||||
\PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions()
|
\PhpOffice\PhpSpreadsheet\Settings::getLibXmlLoaderOptions()
|
||||||
);
|
);
|
||||||
|
|
||||||
$officeNs = $dom->lookupNamespaceUri("office");
|
$officeNs = $dom->lookupNamespaceUri('office');
|
||||||
$tableNs = $dom->lookupNamespaceUri("table");
|
$tableNs = $dom->lookupNamespaceUri('table');
|
||||||
$textNs = $dom->lookupNamespaceUri("text");
|
$textNs = $dom->lookupNamespaceUri('text');
|
||||||
$xlinkNs = $dom->lookupNamespaceUri("xlink");
|
$xlinkNs = $dom->lookupNamespaceUri('xlink');
|
||||||
|
|
||||||
$spreadsheets = $dom->getElementsByTagNameNS($officeNs, "body")
|
$spreadsheets = $dom->getElementsByTagNameNS($officeNs, 'body')
|
||||||
->item(0)
|
->item(0)
|
||||||
->getElementsByTagNameNS($officeNs, "spreadsheet");
|
->getElementsByTagNameNS($officeNs, 'spreadsheet');
|
||||||
|
|
||||||
foreach ($spreadsheets as $workbookData) {
|
foreach ($spreadsheets as $workbookData) {
|
||||||
/** @var \DOMElement $workbookData */
|
/** @var \DOMElement $workbookData */
|
||||||
|
$tables = $workbookData->getElementsByTagNameNS($tableNs, 'table');
|
||||||
$tables = $workbookData->getElementsByTagNameNS($tableNs, "table");
|
|
||||||
|
|
||||||
$worksheetID = 0;
|
$worksheetID = 0;
|
||||||
foreach ($tables as $worksheetDataSet) {
|
foreach ($tables as $worksheetDataSet) {
|
||||||
/** @var \DOMElement $worksheetDataSet */
|
/** @var \DOMElement $worksheetDataSet */
|
||||||
|
$worksheetName = $worksheetDataSet->getAttributeNS($tableNs, 'name');
|
||||||
$worksheetName = $worksheetDataSet->getAttributeNS($tableNs, "name");
|
|
||||||
|
|
||||||
// Check loadSheetsOnly
|
// Check loadSheetsOnly
|
||||||
if (isset($this->loadSheetsOnly)
|
if (isset($this->loadSheetsOnly)
|
||||||
|
@ -435,7 +435,7 @@ class Ods extends BaseReader implements IReader
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create sheet
|
// Create sheet
|
||||||
if($worksheetID > 0){
|
if ($worksheetID > 0) {
|
||||||
$spreadsheet->createSheet(); // First sheet is added by default
|
$spreadsheet->createSheet(); // First sheet is added by default
|
||||||
}
|
}
|
||||||
$spreadsheet->setActiveSheetIndex($worksheetID);
|
$spreadsheet->setActiveSheetIndex($worksheetID);
|
||||||
|
@ -453,15 +453,15 @@ class Ods extends BaseReader implements IReader
|
||||||
/** @var \DOMElement $childNode */
|
/** @var \DOMElement $childNode */
|
||||||
|
|
||||||
// Filter elements which are not under the "table" ns
|
// Filter elements which are not under the "table" ns
|
||||||
if($childNode->namespaceURI != $tableNs){
|
if ($childNode->namespaceURI != $tableNs) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = $childNode->nodeName;
|
$key = $childNode->nodeName;
|
||||||
|
|
||||||
// Remove ns from node name
|
// Remove ns from node name
|
||||||
if(strpos($key, ":") !== false){
|
if (strpos($key, ':') !== false) {
|
||||||
$keyChunks = explode(":", $key);
|
$keyChunks = explode(':', $key);
|
||||||
$key = array_pop($keyChunks);
|
$key = array_pop($keyChunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,16 +478,15 @@ class Ods extends BaseReader implements IReader
|
||||||
break;
|
break;
|
||||||
case 'table-row':
|
case 'table-row':
|
||||||
|
|
||||||
if($childNode->hasAttributeNS($tableNs, 'number-rows-repeated')){
|
if ($childNode->hasAttributeNS($tableNs, 'number-rows-repeated')) {
|
||||||
$rowRepeats = $childNode->getAttributeNS($tableNs, 'number-rows-repeated');
|
$rowRepeats = $childNode->getAttributeNS($tableNs, 'number-rows-repeated');
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$rowRepeats = 1;
|
$rowRepeats = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$columnID = 'A';
|
$columnID = 'A';
|
||||||
foreach ($childNode->childNodes as $key => $cellData) {
|
foreach ($childNode->childNodes as $key => $cellData) {
|
||||||
/** @var \DOMElement $cellData */
|
/* @var \DOMElement $cellData */
|
||||||
|
|
||||||
if ($this->getReadFilter() !== null) {
|
if ($this->getReadFilter() !== null) {
|
||||||
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
|
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
|
||||||
|
@ -501,19 +500,18 @@ class Ods extends BaseReader implements IReader
|
||||||
$hasCalculatedValue = false;
|
$hasCalculatedValue = false;
|
||||||
$cellDataFormula = '';
|
$cellDataFormula = '';
|
||||||
|
|
||||||
if ($cellData->hasAttributeNS($tableNs, "formula")) {
|
if ($cellData->hasAttributeNS($tableNs, 'formula')) {
|
||||||
$cellDataFormula = $cellData->getAttributeNS($tableNs, "formula");
|
$cellDataFormula = $cellData->getAttributeNS($tableNs, 'formula');
|
||||||
$hasCalculatedValue = true;
|
$hasCalculatedValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Annotations
|
// Annotations
|
||||||
$annotation = $cellData->getElementsByTagNameNS($officeNs, "annotation");
|
$annotation = $cellData->getElementsByTagNameNS($officeNs, 'annotation');
|
||||||
|
|
||||||
if ($annotation->length > 0) {
|
if ($annotation->length > 0) {
|
||||||
$textNode = $annotation->item(0)->getElementsByTagNameNS($textNs, "p");
|
$textNode = $annotation->item(0)->getElementsByTagNameNS($textNs, 'p');
|
||||||
|
|
||||||
if($textNode->length > 0){
|
|
||||||
|
|
||||||
|
if ($textNode->length > 0) {
|
||||||
$text = $this->scanElementForText($textNode->item(0));
|
$text = $this->scanElementForText($textNode->item(0));
|
||||||
|
|
||||||
$spreadsheet->getActiveSheet()
|
$spreadsheet->getActiveSheet()
|
||||||
|
@ -532,13 +530,12 @@ class Ods extends BaseReader implements IReader
|
||||||
/** @var \DOMElement $item */
|
/** @var \DOMElement $item */
|
||||||
|
|
||||||
// Filter text:p elements
|
// Filter text:p elements
|
||||||
if($item->nodeName == "text:p"){
|
if ($item->nodeName == 'text:p') {
|
||||||
$paragraphs[] = $item;
|
$paragraphs[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($paragraphs) > 0) {
|
if (count($paragraphs) > 0) {
|
||||||
|
|
||||||
// Consolidate if there are multiple p records (maybe with spans as well)
|
// Consolidate if there are multiple p records (maybe with spans as well)
|
||||||
$dataArray = [];
|
$dataArray = [];
|
||||||
|
|
||||||
|
@ -560,9 +557,9 @@ class Ods extends BaseReader implements IReader
|
||||||
$dataValue = $allCellDataText;
|
$dataValue = $allCellDataText;
|
||||||
|
|
||||||
foreach ($paragraphs as $paragraph) {
|
foreach ($paragraphs as $paragraph) {
|
||||||
$link = $paragraph->getElementsByTagNameNS($textNs, "a");
|
$link = $paragraph->getElementsByTagNameNS($textNs, 'a');
|
||||||
if($link->length > 0){
|
if ($link->length > 0) {
|
||||||
$hyperlink = $link->item(0)->getAttributeNS($xlinkNs, "href");
|
$hyperlink = $link->item(0)->getAttributeNS($xlinkNs, 'href');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +570,7 @@ class Ods extends BaseReader implements IReader
|
||||||
break;
|
break;
|
||||||
case 'percentage':
|
case 'percentage':
|
||||||
$type = DataType::TYPE_NUMERIC;
|
$type = DataType::TYPE_NUMERIC;
|
||||||
$dataValue = (float)$cellData->getAttributeNS($officeNs, 'value');
|
$dataValue = (float) $cellData->getAttributeNS($officeNs, 'value');
|
||||||
|
|
||||||
if (floor($dataValue) == $dataValue) {
|
if (floor($dataValue) == $dataValue) {
|
||||||
$dataValue = (int) $dataValue;
|
$dataValue = (int) $dataValue;
|
||||||
|
@ -582,7 +579,7 @@ class Ods extends BaseReader implements IReader
|
||||||
break;
|
break;
|
||||||
case 'currency':
|
case 'currency':
|
||||||
$type = DataType::TYPE_NUMERIC;
|
$type = DataType::TYPE_NUMERIC;
|
||||||
$dataValue = (float)$cellData->getAttributeNS($officeNs, 'value');
|
$dataValue = (float) $cellData->getAttributeNS($officeNs, 'value');
|
||||||
|
|
||||||
if (floor($dataValue) == $dataValue) {
|
if (floor($dataValue) == $dataValue) {
|
||||||
$dataValue = (int) $dataValue;
|
$dataValue = (int) $dataValue;
|
||||||
|
@ -591,7 +588,7 @@ class Ods extends BaseReader implements IReader
|
||||||
break;
|
break;
|
||||||
case 'float':
|
case 'float':
|
||||||
$type = DataType::TYPE_NUMERIC;
|
$type = DataType::TYPE_NUMERIC;
|
||||||
$dataValue = (float)$cellData->getAttributeNS($officeNs, 'value');
|
$dataValue = (float) $cellData->getAttributeNS($officeNs, 'value');
|
||||||
|
|
||||||
if (floor($dataValue) == $dataValue) {
|
if (floor($dataValue) == $dataValue) {
|
||||||
if ($dataValue == (int) $dataValue) {
|
if ($dataValue == (int) $dataValue) {
|
||||||
|
@ -635,7 +632,6 @@ class Ods extends BaseReader implements IReader
|
||||||
);
|
);
|
||||||
$formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4;
|
$formatting = \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_TIME4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$dataValue = null;
|
$dataValue = null;
|
||||||
}
|
}
|
||||||
|
@ -650,10 +646,8 @@ class Ods extends BaseReader implements IReader
|
||||||
$temp = explode('"', $cellDataFormula);
|
$temp = explode('"', $cellDataFormula);
|
||||||
$tKey = false;
|
$tKey = false;
|
||||||
foreach ($temp as &$value) {
|
foreach ($temp as &$value) {
|
||||||
|
|
||||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||||
if ($tKey = !$tKey) {
|
if ($tKey = !$tKey) {
|
||||||
|
|
||||||
// Cell range reference in another sheet
|
// Cell range reference in another sheet
|
||||||
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value);
|
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value);
|
||||||
|
|
||||||
|
@ -675,16 +669,14 @@ class Ods extends BaseReader implements IReader
|
||||||
$cellDataFormula = implode('"', $temp);
|
$cellDataFormula = implode('"', $temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($cellData->hasAttributeNS($tableNs, 'number-columns-repeated')){
|
if ($cellData->hasAttributeNS($tableNs, 'number-columns-repeated')) {
|
||||||
$colRepeats = (int)$cellData->getAttributeNS($tableNs, 'number-columns-repeated');
|
$colRepeats = (int) $cellData->getAttributeNS($tableNs, 'number-columns-repeated');
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$colRepeats = 1;
|
$colRepeats = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type !== null) {
|
if ($type !== null) {
|
||||||
for ($i = 0; $i < $colRepeats; ++$i) {
|
for ($i = 0; $i < $colRepeats; ++$i) {
|
||||||
|
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
++$columnID;
|
++$columnID;
|
||||||
}
|
}
|
||||||
|
@ -697,10 +689,9 @@ class Ods extends BaseReader implements IReader
|
||||||
->getCell($columnID . $rID);
|
->getCell($columnID . $rID);
|
||||||
|
|
||||||
// Set value
|
// Set value
|
||||||
if($hasCalculatedValue){
|
if ($hasCalculatedValue) {
|
||||||
$cell->setValueExplicit($cellDataFormula, $type);
|
$cell->setValueExplicit($cellDataFormula, $type);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$cell->setValueExplicit($dataValue, $type);
|
$cell->setValueExplicit($dataValue, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,9 +729,8 @@ class Ods extends BaseReader implements IReader
|
||||||
$columnTo = $columnID;
|
$columnTo = $columnID;
|
||||||
|
|
||||||
if ($cellData->hasAttributeNS($tableNs, 'number-columns-spanned')) {
|
if ($cellData->hasAttributeNS($tableNs, 'number-columns-spanned')) {
|
||||||
|
|
||||||
$columnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnID);
|
$columnIndex = \PhpOffice\PhpSpreadsheet\Cell::columnIndexFromString($columnID);
|
||||||
$columnIndex += (int)$cellData->getAttributeNS($tableNs, 'number-columns-spanned');
|
$columnIndex += (int) $cellData->getAttributeNS($tableNs, 'number-columns-spanned');
|
||||||
$columnIndex -= 2;
|
$columnIndex -= 2;
|
||||||
|
|
||||||
$columnTo = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnIndex);
|
$columnTo = \PhpOffice\PhpSpreadsheet\Cell::stringFromColumnIndex($columnIndex);
|
||||||
|
@ -749,7 +739,7 @@ class Ods extends BaseReader implements IReader
|
||||||
$rowTo = $rowID;
|
$rowTo = $rowID;
|
||||||
|
|
||||||
if ($cellData->hasAttributeNS($tableNs, 'number-rows-spanned')) {
|
if ($cellData->hasAttributeNS($tableNs, 'number-rows-spanned')) {
|
||||||
$rowTo = $rowTo + (int)$cellData->getAttributeNS($tableNs, 'number-rows-spanned') - 1;
|
$rowTo = $rowTo + (int) $cellData->getAttributeNS($tableNs, 'number-rows-spanned') - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cellRange = $columnID . $rowID . ':' . $columnTo . $rowTo;
|
$cellRange = $columnID . $rowID . ':' . $columnTo . $rowTo;
|
||||||
|
@ -772,38 +762,35 @@ class Ods extends BaseReader implements IReader
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively scan element
|
* Recursively scan element.
|
||||||
*
|
*
|
||||||
* @param \DOMNode $element
|
* @param \DOMNode $element
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function scanElementForText(\DOMNode $element){
|
protected function scanElementForText(\DOMNode $element)
|
||||||
|
{
|
||||||
$str = "";
|
$str = '';
|
||||||
foreach($element->childNodes as $child){
|
foreach ($element->childNodes as $child) {
|
||||||
/** @var \DOMNode $child */
|
/** @var \DOMNode $child */
|
||||||
|
if ($child->nodeType == XML_TEXT_NODE) {
|
||||||
if($child->nodeType == XML_TEXT_NODE){
|
|
||||||
$str .= $child->nodeValue;
|
$str .= $child->nodeValue;
|
||||||
}
|
} elseif ($child->nodeType == XML_ELEMENT_NODE && $child->nodeName == 'text:s') {
|
||||||
elseif($child->nodeType == XML_ELEMENT_NODE && $child->nodeName == "text:s"){
|
|
||||||
// It's a space
|
// It's a space
|
||||||
|
|
||||||
// Multiple spaces?
|
// Multiple spaces?
|
||||||
if(isset($child->attributes["text:c"])){
|
if (isset($child->attributes['text:c'])) {
|
||||||
|
|
||||||
/** @var \DOMAttr $cAttr */
|
/** @var \DOMAttr $cAttr */
|
||||||
$cAttr = $child->attributes["text:c"];
|
$cAttr = $child->attributes['text:c'];
|
||||||
$multiplier = (int)$cAttr->nodeValue;
|
$multiplier = (int) $cAttr->nodeValue;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$multiplier = 1;
|
$multiplier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str .= str_repeat(" ", $multiplier);
|
$str .= str_repeat(' ', $multiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($child->hasChildNodes()){
|
if ($child->hasChildNodes()) {
|
||||||
$str .= $this->scanElementForText($child);
|
$str .= $this->scanElementForText($child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -813,6 +800,7 @@ class Ods extends BaseReader implements IReader
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $is
|
* @param string $is
|
||||||
|
*
|
||||||
* @return \PhpOffice\PhpSpreadsheet\RichText
|
* @return \PhpOffice\PhpSpreadsheet\RichText
|
||||||
*/
|
*/
|
||||||
private function parseRichText($is = '')
|
private function parseRichText($is = '')
|
||||||
|
|
|
@ -24,9 +24,9 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
|
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
|
||||||
*/
|
*/
|
||||||
protected function loadOOCalcTestFile(){
|
protected function loadOOCalcTestFile()
|
||||||
|
{
|
||||||
if(!$this->spreadsheetOOCalcTest){
|
if (!$this->spreadsheetOOCalcTest) {
|
||||||
$filename = __DIR__ . '/../../../samples/templates/OOCalcTest.ods';
|
$filename = __DIR__ . '/../../../samples/templates/OOCalcTest.ods';
|
||||||
|
|
||||||
// Load into this instance
|
// Load into this instance
|
||||||
|
@ -40,9 +40,9 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
|
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
|
||||||
*/
|
*/
|
||||||
protected function loadDataFile(){
|
protected function loadDataFile()
|
||||||
|
{
|
||||||
if(!$this->spreadsheetData){
|
if (!$this->spreadsheetData) {
|
||||||
$filename = __DIR__ . '/../../data/Reader/Ods/data.ods';
|
$filename = __DIR__ . '/../../data/Reader/Ods/data.ods';
|
||||||
|
|
||||||
// Load into this instance
|
// Load into this instance
|
||||||
|
@ -63,8 +63,8 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
// Test "listWorksheetNames" method
|
// Test "listWorksheetNames" method
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
"Sheet1",
|
'Sheet1',
|
||||||
"Second Sheet",
|
'Second Sheet',
|
||||||
], $reader->listWorksheetNames($filename));
|
], $reader->listWorksheetNames($filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertInstanceOf('PhpOffice\PhpSpreadsheet\Worksheet', $secondSheet);
|
$this->assertInstanceOf('PhpOffice\PhpSpreadsheet\Worksheet', $secondSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReadValueAndComments(){
|
public function testReadValueAndComments()
|
||||||
|
{
|
||||||
$spreadsheet = $this->loadOOCalcTestFile();
|
$spreadsheet = $this->loadOOCalcTestFile();
|
||||||
|
|
||||||
$firstSheet = $spreadsheet->getSheet(0);
|
$firstSheet = $spreadsheet->getSheet(0);
|
||||||
|
@ -93,41 +93,41 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals('N', $firstSheet->getHighestColumn());
|
$this->assertEquals('N', $firstSheet->getHighestColumn());
|
||||||
|
|
||||||
// Simple cell value
|
// Simple cell value
|
||||||
$this->assertEquals("Test String 1", $firstSheet->getCell("A1")->getValue());
|
$this->assertEquals('Test String 1', $firstSheet->getCell('A1')->getValue());
|
||||||
|
|
||||||
// Merged cell
|
// Merged cell
|
||||||
$this->assertEquals("BOX", $firstSheet->getCell("B18")->getValue());
|
$this->assertEquals('BOX', $firstSheet->getCell('B18')->getValue());
|
||||||
|
|
||||||
// Comments/Annotations
|
// Comments/Annotations
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
"Test for a simple colour-formatted string",
|
'Test for a simple colour-formatted string',
|
||||||
$firstSheet->getComment("A1")->getText()->getPlainText()
|
$firstSheet->getComment('A1')->getText()->getPlainText()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Data types
|
// Data types
|
||||||
$this->assertEquals(DataType::TYPE_STRING, $firstSheet->getCell("A1")->getDataType());
|
$this->assertEquals(DataType::TYPE_STRING, $firstSheet->getCell('A1')->getDataType());
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("B1")->getDataType()); // Int
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('B1')->getDataType()); // Int
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("B6")->getDataType()); // Float
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('B6')->getDataType()); // Float
|
||||||
$this->assertEquals(1.23, $firstSheet->getCell("B6")->getValue());
|
$this->assertEquals(1.23, $firstSheet->getCell('B6')->getValue());
|
||||||
$this->assertEquals(0, $firstSheet->getCell("G10")->getValue());
|
$this->assertEquals(0, $firstSheet->getCell('G10')->getValue());
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("A10")->getDataType()); // Date
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A10')->getDataType()); // Date
|
||||||
$this->assertEquals(22269.0, $firstSheet->getCell("A10")->getValue());
|
$this->assertEquals(22269.0, $firstSheet->getCell('A10')->getValue());
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("A13")->getDataType()); // Time
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A13')->getDataType()); // Time
|
||||||
$this->assertEquals(25569.0625, $firstSheet->getCell("A13")->getValue());
|
$this->assertEquals(25569.0625, $firstSheet->getCell('A13')->getValue());
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("A15")->getDataType()); // Date + Time
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A15')->getDataType()); // Date + Time
|
||||||
$this->assertEquals(22269.0625, $firstSheet->getCell("A15")->getValue());
|
$this->assertEquals(22269.0625, $firstSheet->getCell('A15')->getValue());
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("A11")->getDataType()); // Fraction
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A11')->getDataType()); // Fraction
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_BOOL, $firstSheet->getCell("D6")->getDataType());
|
$this->assertEquals(DataType::TYPE_BOOL, $firstSheet->getCell('D6')->getDataType());
|
||||||
$this->assertTrue($firstSheet->getCell("D6")->getValue());
|
$this->assertTrue($firstSheet->getCell('D6')->getValue());
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_FORMULA, $firstSheet->getCell("C6")->getDataType()); // Formula
|
$this->assertEquals(DataType::TYPE_FORMULA, $firstSheet->getCell('C6')->getDataType()); // Formula
|
||||||
$this->assertEquals("=TRUE()", $firstSheet->getCell("C6")->getValue()); // Formula
|
$this->assertEquals('=TRUE()', $firstSheet->getCell('C6')->getValue()); // Formula
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Percentage, Currency
|
* Percentage, Currency
|
||||||
|
@ -137,17 +137,17 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$firstSheet = $spreadsheet->getSheet(0);
|
$firstSheet = $spreadsheet->getSheet(0);
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("A1")->getDataType()); // Percentage (10%)
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A1')->getDataType()); // Percentage (10%)
|
||||||
$this->assertEquals(0.1, $firstSheet->getCell("A1")->getValue());
|
$this->assertEquals(0.1, $firstSheet->getCell('A1')->getValue());
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("A2")->getDataType()); // Percentage (10.00%)
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A2')->getDataType()); // Percentage (10.00%)
|
||||||
$this->assertEquals(0.1, $firstSheet->getCell("A2")->getValue());
|
$this->assertEquals(0.1, $firstSheet->getCell('A2')->getValue());
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("A4")->getDataType()); // Currency (€10.00)
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A4')->getDataType()); // Currency (€10.00)
|
||||||
$this->assertEquals(10, $firstSheet->getCell("A4")->getValue());
|
$this->assertEquals(10, $firstSheet->getCell('A4')->getValue());
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell("A5")->getDataType()); // Currency ($20)
|
$this->assertEquals(DataType::TYPE_NUMERIC, $firstSheet->getCell('A5')->getDataType()); // Currency ($20)
|
||||||
$this->assertEquals(20, $firstSheet->getCell("A5")->getValue());
|
$this->assertEquals(20, $firstSheet->getCell('A5')->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReadColors()
|
public function testReadColors()
|
||||||
|
@ -157,47 +157,46 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
// Background color
|
// Background color
|
||||||
|
|
||||||
$style = $firstSheet->getCell("K3")->getStyle();
|
$style = $firstSheet->getCell('K3')->getStyle();
|
||||||
|
|
||||||
$this->assertEquals("none", $style->getFill()->getFillType());
|
$this->assertEquals('none', $style->getFill()->getFillType());
|
||||||
$this->assertEquals("FFFFFFFF", $style->getFill()->getStartColor()->getARGB());
|
$this->assertEquals('FFFFFFFF', $style->getFill()->getStartColor()->getARGB());
|
||||||
$this->assertEquals("FF000000", $style->getFill()->getEndColor()->getARGB());
|
$this->assertEquals('FF000000', $style->getFill()->getEndColor()->getARGB());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReadRichText(){
|
public function testReadRichText()
|
||||||
|
{
|
||||||
$spreadsheet = $this->loadOOCalcTestFile();
|
$spreadsheet = $this->loadOOCalcTestFile();
|
||||||
$firstSheet = $spreadsheet->getSheet(0);
|
$firstSheet = $spreadsheet->getSheet(0);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
"I don't know if OOCalc supports Rich Text in the same way as Excel, " .
|
"I don't know if OOCalc supports Rich Text in the same way as Excel, " .
|
||||||
"And this row should be autofit height with text wrap",
|
'And this row should be autofit height with text wrap',
|
||||||
$firstSheet->getCell("A28")->getValue()
|
$firstSheet->getCell('A28')->getValue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReadCellsWithRepeatedSpaces(){
|
public function testReadCellsWithRepeatedSpaces()
|
||||||
|
{
|
||||||
$spreadsheet = $this->loadDataFile();
|
$spreadsheet = $this->loadDataFile();
|
||||||
$firstSheet = $spreadsheet->getSheet(0);
|
$firstSheet = $spreadsheet->getSheet(0);
|
||||||
|
|
||||||
$this->assertEquals("This has 4 spaces before and 2 after ", $firstSheet->getCell("A8")->getValue());
|
$this->assertEquals('This has 4 spaces before and 2 after ', $firstSheet->getCell('A8')->getValue());
|
||||||
$this->assertEquals("This only one after ", $firstSheet->getCell("A9")->getValue());
|
$this->assertEquals('This only one after ', $firstSheet->getCell('A9')->getValue());
|
||||||
$this->assertEquals("Test with DIFFERENT styles and multiple spaces: ", $firstSheet->getCell("A10")->getValue());
|
$this->assertEquals('Test with DIFFERENT styles and multiple spaces: ', $firstSheet->getCell('A10')->getValue());
|
||||||
$this->assertEquals("test with new \nLines", $firstSheet->getCell("A11")->getValue());
|
$this->assertEquals("test with new \nLines", $firstSheet->getCell('A11')->getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReadHyperlinks(){
|
public function testReadHyperlinks()
|
||||||
|
{
|
||||||
$spreadsheet = $this->loadOOCalcTestFile();
|
$spreadsheet = $this->loadOOCalcTestFile();
|
||||||
$firstSheet = $spreadsheet->getSheet(0);
|
$firstSheet = $spreadsheet->getSheet(0);
|
||||||
|
|
||||||
$hyperlink = $firstSheet->getCell("A29");
|
$hyperlink = $firstSheet->getCell('A29');
|
||||||
|
|
||||||
$this->assertEquals(DataType::TYPE_STRING, $hyperlink->getDataType());
|
$this->assertEquals(DataType::TYPE_STRING, $hyperlink->getDataType());
|
||||||
$this->assertEquals("PHPExcel", $hyperlink->getValue());
|
$this->assertEquals('PHPExcel', $hyperlink->getValue());
|
||||||
$this->assertEquals("http://www.phpexcel.net/", $hyperlink->getHyperlink()->getUrl());
|
$this->assertEquals('http://www.phpexcel.net/', $hyperlink->getHyperlink()->getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -206,22 +205,22 @@ class OdsTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testReadBoldItalicUnderline()
|
public function testReadBoldItalicUnderline()
|
||||||
{
|
{
|
||||||
$this->markTestSkipped("Features not implemented yet");
|
$this->markTestSkipped('Features not implemented yet');
|
||||||
|
|
||||||
$spreadsheet = $this->loadOOCalcTestFile();
|
$spreadsheet = $this->loadOOCalcTestFile();
|
||||||
$firstSheet = $spreadsheet->getSheet(0);
|
$firstSheet = $spreadsheet->getSheet(0);
|
||||||
|
|
||||||
// Font styles
|
// Font styles
|
||||||
|
|
||||||
$style = $firstSheet->getCell("A1")->getStyle();
|
$style = $firstSheet->getCell('A1')->getStyle();
|
||||||
$this->assertEquals("FF000000", $style->getFont()->getColor()->getARGB());
|
$this->assertEquals('FF000000', $style->getFont()->getColor()->getARGB());
|
||||||
$this->assertEquals(11, $style->getFont()->getSize());
|
$this->assertEquals(11, $style->getFont()->getSize());
|
||||||
$this->assertEquals(Font::UNDERLINE_NONE, $style->getFont()->getUnderline());
|
$this->assertEquals(Font::UNDERLINE_NONE, $style->getFont()->getUnderline());
|
||||||
|
|
||||||
$style = $firstSheet->getCell("E3")->getStyle();
|
$style = $firstSheet->getCell('E3')->getStyle();
|
||||||
$this->assertEquals(Font::UNDERLINE_SINGLE, $style->getFont()->getUnderline());
|
$this->assertEquals(Font::UNDERLINE_SINGLE, $style->getFont()->getUnderline());
|
||||||
|
|
||||||
$style = $firstSheet->getCell("E1")->getStyle();
|
$style = $firstSheet->getCell('E1')->getStyle();
|
||||||
$this->assertTrue($style->getFont()->getBold());
|
$this->assertTrue($style->getFont()->getBold());
|
||||||
$this->assertTrue($style->getFont()->getItalic());
|
$this->assertTrue($style->getFont()->getItalic());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue