Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aVadim483 committed Sep 15, 2024
1 parent 6648e99 commit 17bed92
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/FastExcelReader/Excel.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,17 +628,19 @@ public static function validate(string $file, ?array &$errors = []): bool
$result = true;
$xmlReader = self::createReader($file, [\XMLReader::VALIDATE => true]);

$fileList = $xmlReader->fileList();
\libxml_use_internal_errors(true);
foreach ($fileList as $innerFile) {
$ext = pathinfo($innerFile, PATHINFO_EXTENSION);
if (in_array($ext, ['xml', 'rels', 'vml'])) {
$zipFile = 'zip://' . $file . '#' . $innerFile;
$dom = new \DOMDocument;
$dom->load($zipFile);
$errors = \libxml_get_errors();
if ($errors) {
$result = false;
if (extension_loaded('dom') && extension_loaded('libxml') && function_exists('libxml_use_internal_errors')) {
$fileList = $xmlReader->fileList();
\libxml_use_internal_errors(true);
foreach ($fileList as $innerFile) {
$ext = pathinfo($innerFile, PATHINFO_EXTENSION);
if (in_array($ext, ['xml', 'rels', 'vml'])) {
$zipFile = 'zip://' . $file . '#' . $innerFile;
$dom = new \DOMDocument;
$dom->load($zipFile);
$errors = \libxml_get_errors();
if ($errors) {
$result = false;
}
}
}
}
Expand Down Expand Up @@ -698,6 +700,8 @@ public static function colLetter(int $colNumber): string
}

/**
* Convert date to timestamp
*
* @param $excelDateTime
*
* @return int
Expand Down Expand Up @@ -1186,6 +1190,8 @@ public function hasImages(): bool
}

/**
* Returns the total count of images in the workbook
*
* @return int
*/
public function countImages(): int
Expand All @@ -1201,6 +1207,8 @@ public function countImages(): int
}

/**
* Returns the list of images from the workbook
*
* @return array
*/
public function getImageList(): array
Expand All @@ -1215,6 +1223,9 @@ public function getImageList(): array
return $result;
}

/**
* @return array
*/
public function readStyles(): array
{
if (!isset($this->styles['_'])) {
Expand Down
5 changes: 5 additions & 0 deletions src/FastExcelReader/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ protected function _cellValue($cell, ?array &$additionalData = [])
case 'inlineStr':
// Value is rich text inline
$value = $cell->textContent;
if ($value && $originalValue === null) {
$originalValue = $value;
}
$dataType = 'string';
break;

Expand Down Expand Up @@ -831,6 +834,8 @@ public function readCells(?bool $styleIdxInclude = null): array
* 't' => _type_
* 'o' => _original_value_
*
* @param $styleKey
*
* @return array
*/
public function readCellsWithStyles($styleKey = null): array
Expand Down

0 comments on commit 17bed92

Please sign in to comment.