This commit is contained in:
Jephté Clain 2025-01-23 09:49:07 +04:00
parent 2b4dff08e2
commit 747f61a03d
11 changed files with 172 additions and 153 deletions

4
.idea/nulib-spout.iml generated
View File

@ -2,11 +2,9 @@
<module type="WEB_MODULE" version="4"> <module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="nulib\ext\" /> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="nulib\" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="nulib\ext\" /> <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="nulib\ext\" />
<sourceFolder url="file://$MODULE_DIR$/upstream-3.x/src" isTestSource="false" packagePrefix="OpenSpout\" /> <sourceFolder url="file://$MODULE_DIR$/upstream-3.x/src" isTestSource="false" packagePrefix="OpenSpout\" />
<sourceFolder url="file://$MODULE_DIR$/upstream-4.x/benchmarks" isTestSource="true" packagePrefix="OpenSpout\Benchmarks\" />
<sourceFolder url="file://$MODULE_DIR$/upstream-4.x/src" isTestSource="false" packagePrefix="OpenSpout\" />
<excludeFolder url="file://$MODULE_DIR$/vendor" /> <excludeFolder url="file://$MODULE_DIR$/vendor" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />

View File

@ -39,7 +39,7 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"nulib\\ext\\": "src", "nulib\\": "src",
"OpenSpout\\": "upstream-3.x/src" "OpenSpout\\": "upstream-3.x/src"
} }
}, },

176
composer.lock generated
View File

@ -12,7 +12,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "../nulib", "url": "../nulib",
"reference": "876873d8fc537901bf8a0f4f1d679f93d0fbc0c9" "reference": "0dfb30d395c0516ba14ef3d9eb22e408bfd93d80"
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
@ -72,12 +72,12 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": { "branch-alias": {
"dev-main": "2.5-dev" "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {
@ -146,8 +146,8 @@
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "name": "symfony/polyfill"
} }
}, },
"autoload": { "autoload": {
@ -367,13 +367,13 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": {
"dev-main": "3.x-dev"
},
"phpstan": { "phpstan": {
"includes": [ "includes": [
"extension.neon" "extension.neon"
] ]
},
"branch-alias": {
"dev-main": "3.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -746,16 +746,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.65.0", "version": "v3.68.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f" "reference": "b9db2b2ea3cdba7201067acee46f984ef2397cff"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/79d4f3e77b250a7d8043d76c6af8f0695e8a469f", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/b9db2b2ea3cdba7201067acee46f984ef2397cff",
"reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f", "reference": "b9db2b2ea3cdba7201067acee46f984ef2397cff",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -772,17 +772,17 @@
"react/promise": "^2.0 || ^3.0", "react/promise": "^2.0 || ^3.0",
"react/socket": "^1.0", "react/socket": "^1.0",
"react/stream": "^1.0", "react/stream": "^1.0",
"sebastian/diff": "^4.0 || ^5.0 || ^6.0", "sebastian/diff": "^4.0 || ^5.1 || ^6.0",
"symfony/console": "^5.4 || ^6.0 || ^7.0", "symfony/console": "^5.4 || ^6.4 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", "symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0", "symfony/filesystem": "^5.4 || ^6.4 || ^7.0",
"symfony/finder": "^5.4 || ^6.0 || ^7.0", "symfony/finder": "^5.4 || ^6.4 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0", "symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
"symfony/polyfill-mbstring": "^1.28", "symfony/polyfill-mbstring": "^1.31",
"symfony/polyfill-php80": "^1.28", "symfony/polyfill-php80": "^1.31",
"symfony/polyfill-php81": "^1.28", "symfony/polyfill-php81": "^1.31",
"symfony/process": "^5.4 || ^6.0 || ^7.0", "symfony/process": "^5.4 || ^6.4 || ^7.2",
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" "symfony/stopwatch": "^5.4 || ^6.4 || ^7.0"
}, },
"require-dev": { "require-dev": {
"facile-it/paraunit": "^1.3.1 || ^2.4", "facile-it/paraunit": "^1.3.1 || ^2.4",
@ -794,9 +794,9 @@
"php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5",
"phpunit/phpunit": "^9.6.21 || ^10.5.38 || ^11.4.3", "phpunit/phpunit": "^9.6.22 || ^10.5.40 || ^11.5.2",
"symfony/var-dumper": "^5.4.47 || ^6.4.15 || ^7.1.8", "symfony/var-dumper": "^5.4.48 || ^6.4.15 || ^7.2.0",
"symfony/yaml": "^5.4.45 || ^6.4.13 || ^7.1.6" "symfony/yaml": "^5.4.45 || ^6.4.13 || ^7.2.0"
}, },
"suggest": { "suggest": {
"ext-dom": "For handling output formats in XML", "ext-dom": "For handling output formats in XML",
@ -837,7 +837,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.65.0" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.68.1"
}, },
"funding": [ "funding": [
{ {
@ -845,7 +845,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-11-25T00:39:24+00:00" "time": "2025-01-17T09:20:36+00:00"
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
@ -909,16 +909,16 @@
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v5.3.1", "version": "v5.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "8eea230464783aa9671db8eea6f8c6ac5285794b" "reference": "447a020a1f875a434d62f2a401f53b82a396e494"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494",
"reference": "8eea230464783aa9671db8eea6f8c6ac5285794b", "reference": "447a020a1f875a434d62f2a401f53b82a396e494",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -961,9 +961,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/nikic/PHP-Parser/issues", "issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1" "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0"
}, },
"time": "2024-10-08T18:51:32+00:00" "time": "2024-12-30T11:07:19+00:00"
}, },
{ {
"name": "nulib/tests", "name": "nulib/tests",
@ -1117,16 +1117,16 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.12.12", "version": "1.12.16",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0" "reference": "e0bb5cb78545aae631220735aa706eac633a6be9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e0bb5cb78545aae631220735aa706eac633a6be9",
"reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0", "reference": "e0bb5cb78545aae631220735aa706eac633a6be9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1171,20 +1171,20 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-11-28T22:13:23+00:00" "time": "2025-01-21T14:50:05+00:00"
}, },
{ {
"name": "phpstan/phpstan-phpunit", "name": "phpstan/phpstan-phpunit",
"version": "1.4.1", "version": "1.4.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git", "url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "11d4235fbc6313ecbf93708606edfd3222e44949" "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/11d4235fbc6313ecbf93708606edfd3222e44949", "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/72a6721c9b64b3e4c9db55abbc38f790b318267e",
"reference": "11d4235fbc6313ecbf93708606edfd3222e44949", "reference": "72a6721c9b64b3e4c9db55abbc38f790b318267e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1221,9 +1221,9 @@
"description": "PHPUnit extensions and rules for PHPStan", "description": "PHPUnit extensions and rules for PHPStan",
"support": { "support": {
"issues": "https://github.com/phpstan/phpstan-phpunit/issues", "issues": "https://github.com/phpstan/phpstan-phpunit/issues",
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.1" "source": "https://github.com/phpstan/phpstan-phpunit/tree/1.4.2"
}, },
"time": "2024-11-12T12:43:59+00:00" "time": "2024-12-17T17:20:49+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -1546,16 +1546,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "9.6.21", "version": "9.6.22",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa" "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f80235cb4d3caa59ae09be3adf1ded27521d1a9c",
"reference": "de6abf3b6f8dd955fac3caad3af7a9504e8c2ffa", "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1566,7 +1566,7 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-xml": "*", "ext-xml": "*",
"ext-xmlwriter": "*", "ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.12.0", "myclabs/deep-copy": "^1.12.1",
"phar-io/manifest": "^2.0.4", "phar-io/manifest": "^2.0.4",
"phar-io/version": "^3.2.1", "phar-io/version": "^3.2.1",
"php": ">=7.3", "php": ">=7.3",
@ -1629,7 +1629,7 @@
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues", "issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy", "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.21" "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.22"
}, },
"funding": [ "funding": [
{ {
@ -1645,7 +1645,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-09-19T10:50:18+00:00" "time": "2024-12-05T13:48:26+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",
@ -1869,33 +1869,33 @@
}, },
{ {
"name": "react/child-process", "name": "react/child-process",
"version": "v0.6.5", "version": "v0.6.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/reactphp/child-process.git", "url": "https://github.com/reactphp/child-process.git",
"reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43" "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/reactphp/child-process/zipball/e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", "url": "https://api.github.com/repos/reactphp/child-process/zipball/1721e2b93d89b745664353b9cfc8f155ba8a6159",
"reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", "reference": "1721e2b93d89b745664353b9cfc8f155ba8a6159",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"evenement/evenement": "^3.0 || ^2.0 || ^1.0", "evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"php": ">=5.3.0", "php": ">=5.3.0",
"react/event-loop": "^1.2", "react/event-loop": "^1.2",
"react/stream": "^1.2" "react/stream": "^1.4"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
"react/socket": "^1.8", "react/socket": "^1.16",
"sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"React\\ChildProcess\\": "src" "React\\ChildProcess\\": "src/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -1932,19 +1932,15 @@
], ],
"support": { "support": {
"issues": "https://github.com/reactphp/child-process/issues", "issues": "https://github.com/reactphp/child-process/issues",
"source": "https://github.com/reactphp/child-process/tree/v0.6.5" "source": "https://github.com/reactphp/child-process/tree/v0.6.6"
}, },
"funding": [ "funding": [
{ {
"url": "https://github.com/WyriHaximus", "url": "https://opencollective.com/reactphp",
"type": "github" "type": "open_collective"
},
{
"url": "https://github.com/clue",
"type": "github"
} }
], ],
"time": "2022-09-16T13:41:56+00:00" "time": "2025-01-01T16:37:48+00:00"
}, },
{ {
"name": "react/dns", "name": "react/dns",
@ -3495,12 +3491,12 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": { "branch-alias": {
"dev-main": "2.5-dev" "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {
@ -3773,8 +3769,8 @@
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "name": "symfony/polyfill"
} }
}, },
"autoload": { "autoload": {
@ -3851,8 +3847,8 @@
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "name": "symfony/polyfill"
} }
}, },
"autoload": { "autoload": {
@ -3935,8 +3931,8 @@
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "name": "symfony/polyfill"
} }
}, },
"autoload": { "autoload": {
@ -4009,8 +4005,8 @@
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "name": "symfony/polyfill"
} }
}, },
"autoload": { "autoload": {
@ -4085,8 +4081,8 @@
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "name": "symfony/polyfill"
} }
}, },
"autoload": { "autoload": {
@ -4165,8 +4161,8 @@
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": { "thanks": {
"name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill",
"url": "https://github.com/symfony/polyfill" "name": "symfony/polyfill"
} }
}, },
"autoload": { "autoload": {
@ -4310,12 +4306,12 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": { "branch-alias": {
"dev-main": "2.5-dev" "dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {

View File

@ -9,6 +9,9 @@ use nulib\php\func;
use nulib\php\nur_func; use nulib\php\nur_func;
use nulib\php\time\Date; use nulib\php\time\Date;
use nulib\php\time\DateTime; use nulib\php\time\DateTime;
use nulib\ref\ext\spout\ref_builder;
use nulib\ref\ext\spout\ref_builder_ods;
use nulib\ref\ext\spout\ref_builder_xlsx;
use nulib\str; use nulib\str;
use nulib\web\http; use nulib\web\http;
use OpenSpout\Common\Entity\Cell; use OpenSpout\Common\Entity\Cell;
@ -38,7 +41,7 @@ class SpoutBuilder extends AbstractBuilder {
if ($border === null) $border = new Border(); if ($border === null) $border = new Border();
$part = new BorderPart($name); $part = new BorderPart($name);
if (($color = $params["color"] ?? null) !== null) { if (($color = $params["color"] ?? null) !== null) {
$part->setColor(cl::get(ref_params::COLORS, $color, $color)); $part->setColor(cl::get(ref_builder::COLORS, $color, $color));
} }
if (($width = $params["width"] ?? null) !== null) $part->setWidth($width); if (($width = $params["width"] ?? null) !== null) $part->setWidth($width);
if (($style = $params["style"] ?? null) !== null) $part->setStyle($style); if (($style = $params["style"] ?? null) !== null) $part->setStyle($style);
@ -67,10 +70,10 @@ class SpoutBuilder extends AbstractBuilder {
if (($name = $font["name"] ?? null) !== null) $style->setFontName($name); if (($name = $font["name"] ?? null) !== null) $style->setFontName($name);
if (($size = $font["size"] ?? null) !== null) $style->setFontSize($size); if (($size = $font["size"] ?? null) !== null) $style->setFontSize($size);
if (($color = $font["color"] ?? null) !== null) { if (($color = $font["color"] ?? null) !== null) {
$style->setFontColor(cl::get(ref_params::COLORS, $color, $color)); $style->setFontColor(cl::get(ref_builder::COLORS, $color, $color));
} }
if (($color = $cell["bg_color"] ?? null) !== null) { if (($color = $cell["bg_color"] ?? null) !== null) {
$style->setBackgroundColor(cl::get(ref_params::COLORS, $color, $color)); $style->setBackgroundColor(cl::get(ref_builder::COLORS, $color, $color));
} }
if (($align = $cell["align"] ?? null) !== null) $style->setCellAlignment($align); if (($align = $cell["align"] ?? null) !== null) $style->setCellAlignment($align);
//if (($align = $params["valign"] ?? null) !== null) $style->setCellVerticalAlignment($align); //if (($align = $params["valign"] ?? null) !== null) $style->setCellVerticalAlignment($align);
@ -131,7 +134,7 @@ class SpoutBuilder extends AbstractBuilder {
const TYPE_DATE = true; const TYPE_DATE = true;
/** @var array configuration du writer */ /** @var array configuration du writer */
const WRITER_PARAMS = null; const SPOUT_PARAMS = null;
/** @var array configuration de la première feuille */ /** @var array configuration de la première feuille */
const SHEET_PARAMS = null; const SHEET_PARAMS = null;
@ -144,48 +147,48 @@ class SpoutBuilder extends AbstractBuilder {
function __construct(?string $output, ?array $params=null) { function __construct(?string $output, ?array $params=null) {
parent::__construct($output, $params); parent::__construct($output, $params);
$writerType = $params["ss_type"] ?? null; $ssType = $params["ss_type"] ?? null;
if ($writerType === null) { if ($ssType === null) {
switch (path::ext($this->output)) { switch (path::ext($this->output)) {
case ".ods": case ".ods":
$writerType = self::WRITER_TYPE_ODS; $ssType = self::SS_TYPE_ODS;
break; break;
case ".xlsx": case ".xlsx":
default: default:
$writerType = self::WRITER_TYPE_XLSX; $ssType = self::SS_TYPE_XLSX;
break; break;
} }
} }
$writerParams = $params["spout"] ?? static::WRITER_PARAMS; $spoutParams = $params["spout"] ?? static::SPOUT_PARAMS;
$writerParams["default_column_width"] ??= 10.5; $spoutParams["default_column_width"] ??= 10.5;
self::ensure_style($writerParams["default_row_style"]); self::ensure_style($spoutParams["default_row_style"]);
switch ($writerType) { switch ($ssType) {
case "ods": case "ods":
case self::WRITER_TYPE_ODS: case self::SS_TYPE_ODS:
$writerType = self::WRITER_TYPE_ODS; $ssType = self::SS_TYPE_ODS;
$writer = WriterEntityFactory::createODSWriter(); $ssWriter = WriterEntityFactory::createODSWriter();
self::apply_params($writer, $writerParams, ref_params_ods::WRITER); self::apply_params($ssWriter, $spoutParams, ref_builder_ods::PARAMS_SPOUT);
break; break;
case "xlsx": case "xlsx":
case self::WRITER_TYPE_XLSX: case self::SS_TYPE_XLSX:
default: default:
$writerType = self::WRITER_TYPE_XLSX; $ssType = self::SS_TYPE_XLSX;
$writer = WriterEntityFactory::createXLSXWriter(); $ssWriter = WriterEntityFactory::createXLSXWriter();
self::apply_params($writer, $writerParams, ref_params_xlsx::WRITER); self::apply_params($ssWriter, $spoutParams, ref_builder_xlsx::PARAMS_SPOUT);
break; break;
} }
$defaultColumnWidth = $writerParams["default_column_width"] ?? null; $defaultColumnWidth = $spoutParams["default_column_width"] ?? null;
if ($defaultColumnWidth !== null) $writer->setDefaultColumnWidth($defaultColumnWidth); if ($defaultColumnWidth !== null) $ssWriter->setDefaultColumnWidth($defaultColumnWidth);
$defaultRowHeight = $writerParams["default_row_height"] ?? null; $defaultRowHeight = $spoutParams["default_row_height"] ?? null;
if ($defaultRowHeight !== null) $writer->setDefaultRowHeight($defaultRowHeight); if ($defaultRowHeight !== null) $ssWriter->setDefaultRowHeight($defaultRowHeight);
$defaultRowStyle = $writerParams["default_row_style"] ?? null; $defaultRowStyle = $spoutParams["default_row_style"] ?? null;
if ($defaultRowStyle !== null) $writer->setDefaultRowStyle($defaultRowStyle); if ($defaultRowStyle !== null) $ssWriter->setDefaultRowStyle($defaultRowStyle);
$writer->writeToStream($this->getResource()); $ssWriter->writeToStream($this->getResource());
$this->writerType = $writerType; $this->ssType = $ssType;
$this->writer = $writer; $this->ssWriter = $ssWriter;
$this->writerParams = $writerParams; $this->writerParams = $spoutParams;
$this->typeNumeric = boolval($params["type_numeric"] ?? static::TYPE_NUMERIC); $this->typeNumeric = boolval($params["type_numeric"] ?? static::TYPE_NUMERIC);
$this->typeDate = boolval($params["type_date"] ?? static::TYPE_DATE); $this->typeDate = boolval($params["type_date"] ?? static::TYPE_DATE);
@ -199,12 +202,12 @@ class SpoutBuilder extends AbstractBuilder {
$this->setSheet(null, $sheetParams); $this->setSheet(null, $sheetParams);
} }
const WRITER_TYPE_ODS = 1, WRITER_TYPE_XLSX = 2; const SS_TYPE_ODS = 1, SS_TYPE_XLSX = 2;
/** @var int type de fichier généré */ /** @var int type de fichier généré */
protected int $writerType; protected int $ssType;
protected WriterMultiSheetsAbstract $writer; protected WriterMultiSheetsAbstract $ssWriter;
protected ?array $writerParams; protected ?array $writerParams;
@ -248,7 +251,7 @@ class SpoutBuilder extends AbstractBuilder {
function setSheet($sheetName, ?array $sheetParams=null): self { function setSheet($sheetName, ?array $sheetParams=null): self {
if ($sheetName !== null) $sheetParams["->setName"] = $sheetName; if ($sheetName !== null) $sheetParams["->setName"] = $sheetName;
$writer = $this->writer; $writer = $this->ssWriter;
if ($this->firstSheet) { if ($this->firstSheet) {
$this->firstSheet = false; $this->firstSheet = false;
$sheet = $writer->getCurrentSheet(); $sheet = $writer->getCurrentSheet();
@ -259,18 +262,18 @@ class SpoutBuilder extends AbstractBuilder {
} }
$this->rowStyle = self::STYLE_ROW; $this->rowStyle = self::STYLE_ROW;
switch ($this->writerType) { switch ($this->ssType) {
case self::WRITER_TYPE_ODS: case self::SS_TYPE_ODS:
# appliquer les paramètres de la feuille # appliquer les paramètres de la feuille
$this->apply_params($sheet, $sheetParams, ref_params_ods::SHEET); $this->apply_params($sheet, $sheetParams, ref_builder_ods::PARAMS_SHEET);
break; break;
case self::WRITER_TYPE_XLSX: case self::SS_TYPE_XLSX:
# appliquer les paramètres de la feuille # appliquer les paramètres de la feuille
$this->apply_params($sheet, $sheetParams, ref_params_xlsx::SHEET); $this->apply_params($sheet, $sheetParams, ref_builder_xlsx::PARAMS_SHEET);
# appliquer les paramètres de la vue de la feuille # appliquer les paramètres de la vue de la feuille
$sheetViewParams =& $sheetParams["view"]; $sheetViewParams =& $sheetParams["view"];
$sheetViewParams["->setFreezeRow"] ??= 2; $sheetViewParams["->setFreezeRow"] ??= 2;
$sheet->setSheetView(self::apply_params(new SheetView(), $sheetViewParams, ref_params_xlsx::SHEET_VIEW)); $sheet->setSheetView(self::apply_params(new SheetView(), $sheetViewParams, ref_builder_xlsx::PARAMS_SHEET_VIEW));
break; break;
} }
self::set_defaults($sheetParams, "header_style", [ self::set_defaults($sheetParams, "header_style", [
@ -350,7 +353,7 @@ class SpoutBuilder extends AbstractBuilder {
function _write(array $row, ?array $colStyles=null, ?array $rowStyle=null): void { function _write(array $row, ?array $colStyles=null, ?array $rowStyle=null): void {
$rowParams = null; $rowParams = null;
if ($rowStyle !== null) { if ($rowStyle !== null) {
foreach (array_keys(ref_params::ROW) as $method) { foreach (array_keys(ref_builder::ROW) as $method) {
$value = $rowStyle[$method] ?? null; $value = $rowStyle[$method] ?? null;
unset($rowStyle[$method]); unset($rowStyle[$method]);
if ($value !== null) $rowParams[$method] = $value; if ($value !== null) $rowParams[$method] = $value;
@ -389,8 +392,8 @@ class SpoutBuilder extends AbstractBuilder {
$rowStyle ??= $oddStyle; $rowStyle ??= $oddStyle;
self::ensure_style($rowStyle); self::ensure_style($rowStyle);
$row = WriterEntityFactory::createRow($cells, $rowStyle); $row = WriterEntityFactory::createRow($cells, $rowStyle);
self::apply_params($row, $rowParams, ref_params::ROW); self::apply_params($row, $rowParams, ref_builder::ROW);
$this->writer->addRow($row); $this->ssWriter->addRow($row);
if ($differentOddEven) $this->oddEvenIndex++; if ($differentOddEven) $this->oddEvenIndex++;
} }
@ -414,7 +417,7 @@ class SpoutBuilder extends AbstractBuilder {
} }
protected function _checkOk(): bool { protected function _checkOk(): bool {
$this->writer->close(); $this->ssWriter->close();
$this->rewind(); $this->rewind();
return true; return true;
} }

View File

@ -1,13 +1,31 @@
<?php <?php
namespace nulib\ext\spout; namespace nulib\ref\ext\spout;
use OpenSpout\Common\Entity\Style\Color; use OpenSpout\Common\Entity\Style\Color;
class ref_params { class ref_builder {
const READER = [ const PARAMS = [
# Builder
"output" => "?string",
"schema" => "?array",
"headers" => "?array",
"use_headers" => "bool",
"rows" => "?array",
"cook_func" => "?callable",
"ss_type" => "?string",
# SpoutBuilder
"type_numeric" => "bool",
"type_date" => "bool",
"spout" => self::PARAMS_SPOUT,
"sheet" => self::PARAMS_SHEET,
"sheet_name" => "?string",
"sheet_view" => self::PARAMS_SHEET_VIEW,
# TempStream
"max_memory" => "?int",
"throw_on_error" => "?bool",
]; ];
const WRITER = [ const PARAMS_SPOUT = [
"->setColumnWidth" => ["float", ["int", null]], "->setColumnWidth" => ["float", ["int", null]],
"->setColumnWidthForRange" => ["int", "int", "int"], "->setColumnWidthForRange" => ["int", "int", "int"],
"default_column_width" => "float", "default_column_width" => "float",
@ -15,7 +33,8 @@ class ref_params {
"default_row_style" => self::STYLE, "default_row_style" => self::STYLE,
]; ];
const SHEET = [ const PARAMS_SHEET = [
"view" => self::PARAMS_SHEET_VIEW,
"->setName" => ["string"], "->setName" => ["string"],
"->setIsVisible" => ["bool"], "->setIsVisible" => ["bool"],
"header_style" => self::STYLE, "header_style" => self::STYLE,
@ -24,6 +43,8 @@ class ref_params {
"different_odd_even" => "bool", "different_odd_even" => "bool",
]; ];
const PARAMS_SHEET_VIEW = [];
const ROW = [ const ROW = [
"->setHeight" => ["float"], "->setHeight" => ["float"],
]; ];

View File

@ -0,0 +1,5 @@
<?php
namespace nulib\ref\ext\spout;
class ref_builder_ods extends ref_builder {
}

View File

@ -1,9 +1,9 @@
<?php <?php
namespace nulib\ext\spout; namespace nulib\ref\ext\spout;
class ref_params_xlsx extends ref_params { class ref_builder_xlsx extends ref_builder {
const SHEET = [ const PARAMS_SHEET = [
"view" => self::SHEET_VIEW, "view" => self::PARAMS_SHEET_VIEW,
# copie de parent::SHEET # copie de parent::SHEET
"->setName" => ["string"], "->setName" => ["string"],
"->setIsVisible" => ["bool"], "->setIsVisible" => ["bool"],
@ -13,7 +13,7 @@ class ref_params_xlsx extends ref_params {
"different_odd_even" => "bool", "different_odd_even" => "bool",
]; ];
const SHEET_VIEW = [ const PARAMS_SHEET_VIEW = [
"->setFreezeRow" => ["int"], "->setFreezeRow" => ["int"],
"->setFreezeColumn" => ["string"], "->setFreezeColumn" => ["string"],
"->setZoomScale" => ["int"], "->setZoomScale" => ["int"],
@ -31,5 +31,6 @@ class ref_params_xlsx extends ref_params {
"->setZoomScaleNormal" => ["int"], "->setZoomScaleNormal" => ["int"],
"->setZoomScalePageLayoutView" => ["int"], "->setZoomScalePageLayoutView" => ["int"],
"->setWorkbookViewId" => ["int"], "->setWorkbookViewId" => ["int"],
# copie de parent::PARAMS_SHEET_VIEW
]; ];
} }

View File

@ -1,5 +0,0 @@
<?php
namespace nulib\ext\spout;
class ref_params_ods extends ref_params {
}