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\os\path;
|
||||
use nur\sery\ValueException;
|
||||
use nur\sery\web\http;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\IValueBinder;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\StringValueBinder;
|
||||
|
@ -42,22 +41,13 @@ class SsBuilder extends AbstractBuilder {
|
|||
|
||||
protected int $rowStyle;
|
||||
|
||||
function setWsname(?string $wsname): void {
|
||||
function setWsname(?string $wsname): self {
|
||||
$ss = $this->ss;
|
||||
$this->ws = null;
|
||||
$this->nrow = 0;
|
||||
$this->rowStyle = self::STYLE_ROW;
|
||||
if ($wsname === null) {
|
||||
$ws = $ss->getActiveSheet();
|
||||
} 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);
|
||||
}
|
||||
|
||||
$ws = wsutils::get_ws($wsname, $ss);
|
||||
if ($ws === null) {
|
||||
$ws = $ss->createSheet()->setTitle($wsname);
|
||||
$this->wroteHeaders = false;
|
||||
|
@ -67,6 +57,7 @@ class SsBuilder extends AbstractBuilder {
|
|||
$this->wroteHeaders = $maxRow > 1;
|
||||
}
|
||||
$this->ws = $ws;
|
||||
return $this;
|
||||
}
|
||||
|
||||
function _write(array $row): void {
|
||||
|
|
|
@ -9,6 +9,7 @@ use nur\sery\php\time\DateTime;
|
|||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class SsReader extends AbstractReader {
|
||||
use TAbstractReader;
|
||||
|
@ -58,9 +59,10 @@ class SsReader extends AbstractReader {
|
|||
$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;
|
||||
return $this;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue