modifs.mineures sans commentaires
This commit is contained in:
parent
6cb66688ec
commit
99e074cd85
|
@ -3,7 +3,6 @@ namespace nur\sery\file\csv;
|
||||||
|
|
||||||
use nur\sery\ext\spreadsheet\wsutils;
|
use nur\sery\ext\spreadsheet\wsutils;
|
||||||
use nur\sery\os\path;
|
use nur\sery\os\path;
|
||||||
use nur\sery\ValueException;
|
|
||||||
use nur\sery\web\http;
|
use nur\sery\web\http;
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\IValueBinder;
|
use PhpOffice\PhpSpreadsheet\Cell\IValueBinder;
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\StringValueBinder;
|
use PhpOffice\PhpSpreadsheet\Cell\StringValueBinder;
|
||||||
|
@ -42,22 +41,13 @@ class SsBuilder extends AbstractBuilder {
|
||||||
|
|
||||||
protected int $rowStyle;
|
protected int $rowStyle;
|
||||||
|
|
||||||
function setWsname(?string $wsname): void {
|
function setWsname(?string $wsname): self {
|
||||||
$ss = $this->ss;
|
$ss = $this->ss;
|
||||||
$this->ws = null;
|
$this->ws = null;
|
||||||
$this->nrow = 0;
|
$this->nrow = 0;
|
||||||
$this->rowStyle = self::STYLE_ROW;
|
$this->rowStyle = self::STYLE_ROW;
|
||||||
if ($wsname === null) {
|
|
||||||
$ws = $ss->getActiveSheet();
|
$ws = wsutils::get_ws($wsname, $ss);
|
||||||
} elseif (is_numeric($wsname)) {
|
|
||||||
$sheetCount = $ss->getSheetCount();
|
|
||||||
if ($wsname < 1 || $wsname > $sheetCount) {
|
|
||||||
throw ValueException::invalid_value($wsname, "sheet index");
|
|
||||||
}
|
|
||||||
$ws = $ss->getSheet($wsname - 1);
|
|
||||||
} else {
|
|
||||||
$ws = $ss->getSheetByName($wsname);
|
|
||||||
}
|
|
||||||
if ($ws === null) {
|
if ($ws === null) {
|
||||||
$ws = $ss->createSheet()->setTitle($wsname);
|
$ws = $ss->createSheet()->setTitle($wsname);
|
||||||
$this->wroteHeaders = false;
|
$this->wroteHeaders = false;
|
||||||
|
@ -67,6 +57,7 @@ class SsBuilder extends AbstractBuilder {
|
||||||
$this->wroteHeaders = $maxRow > 1;
|
$this->wroteHeaders = $maxRow > 1;
|
||||||
}
|
}
|
||||||
$this->ws = $ws;
|
$this->ws = $ws;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _write(array $row): void {
|
function _write(array $row): void {
|
||||||
|
|
|
@ -9,6 +9,7 @@ use nur\sery\php\time\DateTime;
|
||||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||||
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||||
|
|
||||||
class SsReader extends AbstractReader {
|
class SsReader extends AbstractReader {
|
||||||
use TAbstractReader;
|
use TAbstractReader;
|
||||||
|
@ -58,9 +59,10 @@ class SsReader extends AbstractReader {
|
||||||
$this->wsname = $params["wsname"] ?? static::WSNAME;
|
$this->wsname = $params["wsname"] ?? static::WSNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ?string $wsname;
|
/** @var string|int|null */
|
||||||
|
protected $wsname;
|
||||||
|
|
||||||
function setWsname(?string $wsname): self {
|
function setWsname($wsname): self {
|
||||||
$this->wsname = $wsname;
|
$this->wsname = $wsname;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue