nulib-spout/patches/v3.7.4.patch

78 lines
3.1 KiB
Diff
Raw Normal View History

diff --git a/src/Writer/WriterAbstract.php b/src/Writer/WriterAbstract.php
index fd7c472..a2a5e37 100644
--- a/src/Writer/WriterAbstract.php
+++ b/src/Writer/WriterAbstract.php
@@ -22,6 +22,9 @@ abstract class WriterAbstract implements WriterInterface
/** @var resource Pointer to the file/stream we will write to */
protected $filePointer;
+ /** @var bool faut-il garder ouvert le flux quand close() est appelé? */
+ protected $dontCloseFilePointer = false;
+
/** @var bool Indicates whether the writer has been opened or not */
protected $isWriterOpened = false;
@@ -57,6 +60,20 @@ abstract class WriterAbstract implements WriterInterface
return $this;
}
+ public function writeToStream($filePointer)
+ {
+ $this->outputFilePath = null;
+
+ $this->filePointer = $filePointer;
+ $this->dontCloseFilePointer = true;
+ $this->throwIfFilePointerIsNotAvailable();
+
+ $this->openWriter();
+ $this->isWriterOpened = true;
+
+ return $this;
+ }
+
/**
* {@inheritdoc}
*/
@@ -177,7 +194,7 @@ abstract class WriterAbstract implements WriterInterface
$this->closeWriter();
- if (\is_resource($this->filePointer)) {
+ if (!$this->dontCloseFilePointer && \is_resource($this->filePointer)) {
$this->globalFunctionsHelper->fclose($this->filePointer);
}
diff --git a/src/Reader/XLSX/Helper/CellValueFormatter.php b/src/Reader/XLSX/Helper/CellValueFormatter.php
index 1734fb5..08e5282 100644
--- a/src/Reader/XLSX/Helper/CellValueFormatter.php
+++ b/src/Reader/XLSX/Helper/CellValueFormatter.php
@@ -268,9 +268,13 @@ class CellValueFormatter
$dateObj->modify('+'.$secondsRemainder.'seconds');
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/Manager/OptionsManager.php b/src/Reader/XLSX/Manager/OptionsManager.php
index b04b92c..5749f65 100644
--- a/src/Reader/XLSX/Manager/OptionsManager.php
+++ b/src/Reader/XLSX/Manager/OptionsManager.php
@@ -29,7 +29,7 @@ class OptionsManager extends OptionsManagerAbstract
protected function setDefaultOptions()
{
$this->setOption(Options::TEMP_FOLDER, sys_get_temp_dir());
- $this->setOption(Options::SHOULD_FORMAT_DATES, false);
+ $this->setOption(Options::SHOULD_FORMAT_DATES, true);
$this->setOption(Options::SHOULD_PRESERVE_EMPTY_ROWS, false);
$this->setOption(Options::SHOULD_USE_1904_DATES, false);
}