application des modifs nulib/spout pour v4.27.0
This commit is contained in:
parent
09540b1767
commit
37ce992b3e
91
patches/v4.27.0.patch
Normal file
91
patches/v4.27.0.patch
Normal file
@ -0,0 +1,91 @@
|
||||
diff --git a/src/Reader/XLSX/Helper/CellValueFormatter.php b/src/Reader/XLSX/Helper/CellValueFormatter.php
|
||||
index 776de0a..bc7a5c4 100644
|
||||
--- a/src/Reader/XLSX/Helper/CellValueFormatter.php
|
||||
+++ b/src/Reader/XLSX/Helper/CellValueFormatter.php
|
||||
@@ -284,9 +284,13 @@ final class CellValueFormatter
|
||||
\assert(false !== $dateObj);
|
||||
|
||||
if ($this->shouldFormatDates) {
|
||||
- $styleNumberFormatCode = $this->styleManager->getNumberFormatCode($cellStyleId);
|
||||
- $phpDateFormat = DateFormatHelper::toPHPDateFormat($styleNumberFormatCode);
|
||||
+ //$styleNumberFormatCode = $this->styleManager->getNumberFormatCode($cellStyleId);
|
||||
+ //$phpDateFormat = DateFormatHelper::toPHPDateFormat($styleNumberFormatCode);
|
||||
+ // Toujours utiliser le format français complet
|
||||
+ $phpDateFormat = "d/m/Y H:i:s";
|
||||
$cellValue = $dateObj->format($phpDateFormat);
|
||||
+ // Enlever la composante heure si elle n'existe pas
|
||||
+ $cellValue = preg_replace('/ 00:00:00$/', "", $cellValue);
|
||||
} else {
|
||||
$cellValue = $dateObj;
|
||||
}
|
||||
diff --git a/src/Reader/XLSX/Options.php b/src/Reader/XLSX/Options.php
|
||||
index 636d2a4..e8609b5 100644
|
||||
--- a/src/Reader/XLSX/Options.php
|
||||
+++ b/src/Reader/XLSX/Options.php
|
||||
@@ -10,7 +10,7 @@ final class Options
|
||||
{
|
||||
use TempFolderOptionTrait;
|
||||
|
||||
- public bool $SHOULD_FORMAT_DATES = false;
|
||||
+ public bool $SHOULD_FORMAT_DATES = true;
|
||||
public bool $SHOULD_PRESERVE_EMPTY_ROWS = false;
|
||||
public bool $SHOULD_USE_1904_DATES = false;
|
||||
public bool $SHOULD_LOAD_MERGE_CELLS = false;
|
||||
diff --git a/src/Writer/AbstractWriter.php b/src/Writer/AbstractWriter.php
|
||||
index eef34fb..a22e90f 100644
|
||||
--- a/src/Writer/AbstractWriter.php
|
||||
+++ b/src/Writer/AbstractWriter.php
|
||||
@@ -13,6 +13,12 @@ abstract class AbstractWriter implements WriterInterface
|
||||
/** @var resource Pointer to the file/stream we will write to */
|
||||
protected $filePointer;
|
||||
|
||||
+ /**
|
||||
+ * @var bool faut-il garder ouvert le flux quand {@link self::close()} est
|
||||
+ * appelé?
|
||||
+ */
|
||||
+ protected bool $dontCloseFilePointer = false;
|
||||
+
|
||||
/** @var string document creator */
|
||||
protected string $creator = 'OpenSpout';
|
||||
|
||||
@@ -20,7 +26,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
protected static string $headerContentType;
|
||||
|
||||
/** @var string Path to the output file */
|
||||
- private string $outputFilePath;
|
||||
+ private ?string $outputFilePath;
|
||||
|
||||
/** @var bool Indicates whether the writer has been opened or not */
|
||||
private bool $isWriterOpened = false;
|
||||
@@ -51,6 +57,20 @@ abstract class AbstractWriter implements WriterInterface
|
||||
$this->isWriterOpened = true;
|
||||
}
|
||||
|
||||
+ final public function writeToStream($filePointer): void
|
||||
+ {
|
||||
+ if (!is_resource($filePointer)) {
|
||||
+ throw new IOException("filePointer is not a resource");
|
||||
+ }
|
||||
+ $this->outputFilePath = null;
|
||||
+
|
||||
+ $this->filePointer = $filePointer;
|
||||
+ $this->dontCloseFilePointer = true;
|
||||
+
|
||||
+ $this->openWriter();
|
||||
+ $this->isWriterOpened = true;
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@@ -140,7 +160,9 @@ abstract class AbstractWriter implements WriterInterface
|
||||
|
||||
$this->closeWriter();
|
||||
|
||||
- fclose($this->filePointer);
|
||||
+ if (!$this->dontCloseFilePointer) {
|
||||
+ fclose($this->filePointer);
|
||||
+ }
|
||||
|
||||
$this->isWriterOpened = false;
|
||||
}
|
@ -284,9 +284,13 @@ final readonly class CellValueFormatter
|
||||
\assert(false !== $dateObj);
|
||||
|
||||
if ($this->shouldFormatDates) {
|
||||
$styleNumberFormatCode = $this->styleManager->getNumberFormatCode($cellStyleId);
|
||||
$phpDateFormat = DateFormatHelper::toPHPDateFormat($styleNumberFormatCode);
|
||||
//$styleNumberFormatCode = $this->styleManager->getNumberFormatCode($cellStyleId);
|
||||
//$phpDateFormat = DateFormatHelper::toPHPDateFormat($styleNumberFormatCode);
|
||||
// Toujours utiliser le format français complet
|
||||
$phpDateFormat = "d/m/Y H:i:s";
|
||||
$cellValue = $dateObj->format($phpDateFormat);
|
||||
// Enlever la composante heure si elle n'existe pas
|
||||
$cellValue = preg_replace('/ 00:00:00$/', "", $cellValue);
|
||||
} else {
|
||||
$cellValue = $dateObj;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ final class Options
|
||||
{
|
||||
use TempFolderOptionTrait;
|
||||
|
||||
public bool $SHOULD_FORMAT_DATES = false;
|
||||
public bool $SHOULD_FORMAT_DATES = true;
|
||||
public bool $SHOULD_PRESERVE_EMPTY_ROWS = false;
|
||||
public bool $SHOULD_USE_1904_DATES = false;
|
||||
public bool $SHOULD_LOAD_MERGE_CELLS = false;
|
||||
|
@ -13,6 +13,12 @@ abstract class AbstractWriter implements WriterInterface
|
||||
/** @var resource Pointer to the file/stream we will write to */
|
||||
protected $filePointer;
|
||||
|
||||
/**
|
||||
* @var bool faut-il garder ouvert le flux quand {@link self::close()} est
|
||||
* appelé?
|
||||
*/
|
||||
protected bool $dontCloseFilePointer = false;
|
||||
|
||||
/** @var string document creator */
|
||||
protected string $creator = 'OpenSpout';
|
||||
|
||||
@ -20,7 +26,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
protected static string $headerContentType;
|
||||
|
||||
/** @var string Path to the output file */
|
||||
private string $outputFilePath;
|
||||
private ?string $outputFilePath;
|
||||
|
||||
/** @var bool Indicates whether the writer has been opened or not */
|
||||
private bool $isWriterOpened = false;
|
||||
@ -51,6 +57,20 @@ abstract class AbstractWriter implements WriterInterface
|
||||
$this->isWriterOpened = true;
|
||||
}
|
||||
|
||||
final public function writeToStream($filePointer): void
|
||||
{
|
||||
if (!is_resource($filePointer)) {
|
||||
throw new IOException("filePointer is not a resource");
|
||||
}
|
||||
$this->outputFilePath = null;
|
||||
|
||||
$this->filePointer = $filePointer;
|
||||
$this->dontCloseFilePointer = true;
|
||||
|
||||
$this->openWriter();
|
||||
$this->isWriterOpened = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
@ -140,7 +160,9 @@ abstract class AbstractWriter implements WriterInterface
|
||||
|
||||
$this->closeWriter();
|
||||
|
||||
fclose($this->filePointer);
|
||||
if (!$this->dontCloseFilePointer) {
|
||||
fclose($this->filePointer);
|
||||
}
|
||||
|
||||
$this->isWriterOpened = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user