support du formatage des lignes et colonnes

This commit is contained in:
Jephté Clain 2024-11-29 16:01:17 +04:00
parent bda119cbed
commit 8258dd53b5
5 changed files with 564 additions and 196 deletions

385
composer.lock generated
View File

@ -12,10 +12,12 @@
"source": {
"type": "git",
"url": "https://git.univ-reunion.fr/sda-php/nulib.git",
"reference": "2a35a6de7105ab2e14edf912d3c47de1513da6d2"
"reference": "4c138708edef5b4ed958a252e9d6038ad0a78ccc"
},
"require": {
"php": "^7.4"
"ext-json": "*",
"php": "^7.4",
"symfony/yaml": "^5.0"
},
"require-dev": {
"ext-curl": "*",
@ -47,7 +49,228 @@
}
],
"description": "fonctions et classes essentielles",
"time": "2024-11-28T15:57:48+00:00"
"time": "2024-11-29T11:46:34+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v2.5.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
"reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:11:13+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"provide": {
"ext-ctype": "*"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/yaml",
"version": "v5.4.45",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "a454d47278cc16a5db371fe73ae66a78a633371e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/a454d47278cc16a5db371fe73ae66a78a633371e",
"reference": "a454d47278cc16a5db371fe73ae66a78a633371e",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
"symfony/console": "<5.3"
},
"require-dev": {
"symfony/console": "^5.3|^6.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"bin": [
"Resources/bin/yaml-lint"
],
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v5.4.45"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:11:13+00:00"
}
],
"packages-dev": [
@ -892,16 +1115,16 @@
},
{
"name": "phpstan/phpstan",
"version": "1.12.11",
"version": "1.12.12",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733"
"reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d1fc20a962a91be578bcfe7cf939e6e1a2ff733",
"reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0",
"reference": "b5ae1b88f471d3fd4ba1aa0046234b5ca3776dd0",
"shasum": ""
},
"require": {
@ -946,7 +1169,7 @@
"type": "github"
}
],
"time": "2024-11-17T14:08:01+00:00"
"time": "2024-11-28T22:13:23+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
@ -3162,73 +3385,6 @@
],
"time": "2024-11-06T11:30:55+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v2.5.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "605389f2a7e5625f273b53960dc46aeaf9c62918"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918",
"reference": "605389f2a7e5625f273b53960dc46aeaf9c62918",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:11:13+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v5.4.45",
@ -3592,85 +3748,6 @@
],
"time": "2024-09-25T14:11:13+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.31.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638",
"reference": "a3cc8b044a6ea513310cbd48ef7333b384945638",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"provide": {
"ext-ctype": "*"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-09T11:45:10+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
"version": "v1.31.0",

View File

@ -1,14 +1,19 @@
<?php
namespace nulib\ext\spout;
use nulib\cl;
use nulib\file\tab\AbstractBuilder;
use nulib\file\tab\TAbstractBuilder;
use nulib\os\path;
use nulib\php\func;
use nulib\php\nur_func;
use nulib\php\time\Date;
use nulib\php\time\DateTime;
use nulib\str;
use nulib\web\http;
use OpenSpout\Common\Entity\Cell;
use OpenSpout\Common\Entity\Style\Border;
use OpenSpout\Common\Entity\Style\BorderPart;
use OpenSpout\Common\Entity\Style\Style;
use OpenSpout\Common\Helper\CellTypeHelper;
use OpenSpout\Writer\Common\Creator\WriterEntityFactory;
@ -28,11 +33,92 @@ class SpoutBuilder extends AbstractBuilder {
/** @var bool faut-il choisir le type date pour une chaine au bon format? */
const TYPE_DATE = true;
/** @var string|int|null nom de la feuille dans laquelle écrire */
/** @var array configuration du writer */
const WRITER_PARAMS = null;
/** @var array options du writer */
const WRITER_OPTIONS_PARAMS = null;
/** @var array configuration de la première feuille */
const SHEET_PARAMS = null;
/** @var array configuration de la vue de la première feuille */
const SHEET_VIEW_PARAMS = null;
/**
* @var string|int|null nom de la feuille dans laquelle écrire.
*
* spécifier cette valeur est équivalent à spécifier la clé "->setName" de
* SHEET_PARAMS
*/
const WSNAME = null;
/** @var array|null paramètres de la feuille dans laquelle écrire */
const WSPARAMS = null;
protected static function apply_params($object, ?array $params, array $refParams) {
foreach (array_keys($refParams) as $method) {
if (!str::starts_with("->", $method)) continue;
if (cl::has($params, $method)) {
func::with([$object, $method])->invoke(cl::with($params[$method]));
}
}
return $object;
}
protected static function add_border_part(?Border &$border, string $name, ?array $params): void {
if ($params === null) return;
if ($border === null) $border = new Border();
$part = new BorderPart($name, $border);
if (($color = $params["color"] ?? null) !== null) {
$part->setColor(cl::get(ref_params::COLORS, $color, $color));
}
if (($width = $params["width"] ?? null) !== null) $part->setWidth($width);
if (($style = $params["style"] ?? null) !== null) $part->setStyle($style);
$border->addPart($part);
}
protected static function set_defaults(?array &$params, string $key, array $defaults): void {
if ($params !== null && array_key_exists($key, $params)) {
if ($params[$key] === false) $params[$key] = null;
} else {
$params[$key] ??= $defaults;
}
}
protected static function ensure_style(&$style): ?Style {
if ($style === null) return null;
if ($style instanceof Style) return $style;
$cell = $style;
$style = new Style();
$font = $cell["font"] ?? null;
if ($font["bold"] ?? null) $style->setFontBold();
if ($font["italic"] ?? null) $style->setFontItalic();
if ($font["underline"] ?? null) $style->setFontUnderline();
if ($font["strikethrough"] ?? null) $style->setFontStrikethrough();
if (($name = $font["name"] ?? null) !== null) $style->setFontName($name);
if (($size = $font["size"] ?? null) !== null) $style->setFontSize($size);
if (($color = $font["color"] ?? null) !== null) {
$style->setFontColor(cl::get(ref_params::COLORS, $color, $color));
}
if (($color = $cell["bg_color"] ?? null) !== null) {
$style->setBackgroundColor(cl::get(ref_params::COLORS, $color, $color));
}
if (($align = $cell["align"] ?? null) !== null) $style->setCellAlignment($align);
//if (($align = $params["valign"] ?? null) !== null) $style->setCellVerticalAlignment($align);
if ($cell["wrap_text"] ?? null) $style->setShouldWrapText();
if (($format = $cell["format"] ?? null) !== null) $style->setFormat($format);
if (($border = $cell["border"] ?? null) !== null) {
$top = $border["top"] ?? null;
$right = $border["right"] ?? null;
$bottom = $border["bottom"] ?? null;
$left = $border["left"] ?? null;
$border = null;
self::add_border_part($border, "top", $top);
self::add_border_part($border, "right", $right);
self::add_border_part($border, "bottom", $bottom);
self::add_border_part($border, "left", $left);
if ($border !== null) $style->setBorder($border);
}
return $style;
}
function __construct(?string $output, ?array $params=null) {
parent::__construct($output, $params);
@ -40,51 +126,76 @@ class SpoutBuilder extends AbstractBuilder {
if ($ssType === null) {
switch (path::ext($this->output)) {
case ".ods":
$ssType = "ods";
$ssType = self::SS_TYPE_ODS;
break;
case ".xlsx":
default:
$ssType = "xlsx";
$ssType = self::SS_TYPE_XLSX;
break;
}
}
switch ($ssType) {
case "ods":
case self::SS_TYPE_ODS:
$ss = WriterEntityFactory::createODSWriter();
break;
case "xlsx":
case self::SS_TYPE_XLSX:
default:
$ss = WriterEntityFactory::createXLSXWriter();
break;
}
$ss->setDefaultColumnWidth(10.5);
$ss->writeToStream($this->getResource());
$this->ssType = $ssType;
$this->ss = $ss;
$this->typeNumeric = boolval($params["type_numeric"] ?? static::TYPE_NUMERIC);
$this->typeDate = boolval($params["type_date"] ?? static::TYPE_DATE);
$this->firstSheet = true;
$wsparams = $params["wsparams"] ?? static::WSPARAMS;
$this->setWsname($params["wsname"] ?? static::WSNAME, $wsparams);
$sheetParams = $params["sheet"] ?? static::SHEET_PARAMS;
$sheetViewParams = $params["sheet_view"] ?? static::SHEET_VIEW_PARAMS;
if ($sheetViewParams !== null) $sheetParams["view"] = $sheetViewParams;
$this->sheetParams = null;
$this->setSheet($params["wsname"] ?? static::WSNAME, $sheetParams);
}
const SS_TYPE_ODS = 0, SS_TYPE_XLSX = 1;
/** @var int type de fichier généré */
protected int $ssType;
protected WriterMultiSheetsAbstract $ss;
protected bool $typeNumeric;
protected bool $typeDate;
function setParams(?array $params): self {
if ($params !== null) {
if (array_key_exists("type_numeric", $params)) {
$this->typeNumeric = boolval($params["type_numeric"] ?? static::TYPE_NUMERIC);
}
if (array_key_exists("type_date", $params)) {
$this->typeDate = boolval($params["type_date"] ?? static::TYPE_DATE);
}
}
return $this;
}
protected bool $firstSheet;
protected ?array $sheetParams;
const STYLE_ROW = 0, STYLE_HEADER = 1;
protected int $rowStyle;
protected bool $firstSheet;
/**
* @param string|int|null $wsname
* @param string|int|null $sheetName
*/
function setWsname($wsname, ?array $params=null): self {
function setSheet($sheetName, ?array $sheetParams=null): self {
if ($sheetName !== null) $sheetParams["->setName"] = $sheetName;
$ss = $this->ss;
$this->rowStyle = self::STYLE_ROW;
if ($this->firstSheet) {
$this->firstSheet = false;
$ws = $ss->getCurrentSheet();
@ -93,25 +204,49 @@ class SpoutBuilder extends AbstractBuilder {
$this->wroteHeaders = false;
$this->built = false;
}
$wsname ??= $params["wsname"] ?? null;
if ($wsname !== null) $ws->setName($wsname);
$sheetView = (new SheetView())
->setFreezeRow($params["sheetView_freezeRow"] ?? 2);
$ws->setSheetView($sheetView);
if ($params !== null) {
if (array_key_exists("schema", $params)) {
$this->schema = $params["schema"] ?? null;
$this->rowStyle = self::STYLE_ROW;
switch ($this->ssType) {
case self::SS_TYPE_ODS:
# appliquer les paramètres de la feuille
$this->apply_params($ss, $sheetParams, ref_params_ods::SHEET);
break;
case self::SS_TYPE_XLSX:
# appliquer les paramètres de la feuille
$this->apply_params($ss, $sheetParams, ref_params_xlsx::SHEET);
# appliquer les paramètres de la vue de la feuille
$sheetViewParams =& $sheetParams["view"];
$sheetViewParams["->setFreezeRow"] ??= 2;
$ws->setSheetView($this->apply_params(new SheetView(), $sheetViewParams, ref_params_xlsx::SHEET_VIEW));
self::set_defaults($sheetParams, "header_style", [
"font" => ["bold" => true],
"bg_color" => "gray",
]);
self::set_defaults($sheetParams, "even_style", [
"bg_color" => "light_gray",
]);
$this->ensure_style($sheetParams["default_style"]);
$this->ensure_style($sheetParams["header_style"]);
$this->ensure_style($sheetParams["odd_style"]);
$this->ensure_style($sheetParams["even_style"]);
break;
}
$this->sheetParams = $sheetParams;
if ($sheetParams !== null) {
if (array_key_exists("schema", $sheetParams)) {
$this->schema = $sheetParams["schema"] ?? null;
}
if (array_key_exists("headers", $params)) {
$this->headers = $params["headers"] ?? null;
if (array_key_exists("headers", $sheetParams)) {
$this->headers = $sheetParams["headers"] ?? null;
}
if (array_key_exists("rows", $params)) {
$rows = $params["rows"] ?? null;
if (array_key_exists("rows", $sheetParams)) {
$rows = $sheetParams["rows"] ?? null;
if (is_callable($rows)) $rows = $rows();
$this->rows = $rows;
}
if (array_key_exists("cook_func", $params)) {
$cookFunc = $params["cook_func"] ?? null;
if (array_key_exists("cook_func", $sheetParams)) {
$cookFunc = $sheetParams["cook_func"] ?? null;
$cookCtx = $cookArgs = null;
if ($cookFunc !== null) {
nur_func::ensure_func($cookFunc, $this, $cookArgs);
@ -120,12 +255,6 @@ class SpoutBuilder extends AbstractBuilder {
$this->cookCtx = $cookCtx;
$this->cookArgs = $cookArgs;
}
if (array_key_exists("type_numeric", $params)) {
$this->typeNumeric = boolval($params["type_numeric"] ?? static::TYPE_NUMERIC);
}
if (array_key_exists("type_date", $params)) {
$this->typeDate = boolval($params["type_date"] ?? static::TYPE_DATE);
}
}
return $this;
}
@ -138,28 +267,37 @@ class SpoutBuilder extends AbstractBuilder {
protected function isDate(&$value, &$style): bool {
if (CellTypeHelper::isDateTimeOrDateInterval($value)) {
$style = (new Style())->setFormat(self::DATE_FORMAT);
$style ??= new Style();
$style->setFormat(self::DATE_FORMAT);
return true;
}
if (!is_string($value) || !$this->typeDate) return false;
if (DateTime::isa_datetime($value, true)) {
$value = new DateTime($value);
$style = (new Style())->setFormat(self::DATETIME_FORMAT);
$style ??= new Style();
$style->setFormat(self::DATETIME_FORMAT);
return true;
}
if (DateTime::isa_date($value, true)) {
$value = new Date($value);
$style = (new Style())->setFormat(self::DATE_FORMAT);
$style ??= new Style();
$style->setFormat(self::DATE_FORMAT);
return true;
}
return false;
}
function _write(array $row): void {
function _write(array $row, ?array $colsStyle=null, ?array $rowStyle=null): void {
$sheetParams = $this->sheetParams;
$defaultStyle = $sheetParams["default_style"];
$headerStyle = $sheetParams["header_style"];
$oddStyle = $sheetParams["odd_style"];
$evenStyle = $sheetParams["even_style"];
$cells = [];
$rowStyle = null;
foreach ($row as $col) {
$style = null;
foreach ($row as $key => $col) {
$style = $colsStyle[$key] ?? null;
self::ensure_style($style);
if ($col === null || $col === "") {
$type = Cell::TYPE_EMPTY;
} elseif ($this->isNumeric($col)) {
@ -174,8 +312,13 @@ class SpoutBuilder extends AbstractBuilder {
$cells[] = $cell;
}
if ($this->rowStyle === self::STYLE_HEADER) {
$rowStyle = (new Style())->setFontBold();
$rowStyle ??= $headerStyle;
} elseif (($this->index + 1) % 2 == 0) {
$rowStyle ??= $evenStyle;
} else {
$rowStyle ??= $oddStyle;
}
$rowStyle ??= $defaultStyle;
$this->ss->addRow(WriterEntityFactory::createRow($cells, $rowStyle));
}

46
src/spout/ref_params.php Normal file
View File

@ -0,0 +1,46 @@
<?php
namespace nulib\ext\spout;
use OpenSpout\Common\Entity\Style\Color;
class ref_params {
public const COLORS = [
"black" => Color::BLACK,
"white" => Color::WHITE,
"red" => Color::RED,
"dark_red" => Color::DARK_RED,
"orange" => Color::ORANGE,
"yellow" => Color::YELLOW,
"light_green" => Color::LIGHT_GREEN,
"green" => Color::GREEN,
"light_blue" => Color::LIGHT_BLUE,
"blue" => Color::BLUE,
"dark_blue" => Color::DARK_BLUE,
"purple" => Color::PURPLE,
"light_gray" => "EEEEEE",
"gray" => "B2B2B2",
];
const STYLE = [
"font" => [
"bold" => "bool",
"italic" => "bool",
"underline" => "bool",
"strikethrough" => "bool",
"name" => "string",
"size" => "int",
"color" => "string",
],
"bg_color" => "string",
"align" => "string",
"valign" => "string",
"wrap_text" => "bool",
"format" => "string",
"border" => [
"top" => ["color" => "string", "width" => "string", "style" => "string"],
"right" => ["color" => "string", "width" => "string", "style" => "string"],
"bottom" => ["color" => "string", "width" => "string", "style" => "string"],
"left" => ["color" => "string", "width" => "string", "style" => "string"],
],
];
}

View File

@ -0,0 +1,24 @@
<?php
namespace nulib\ext\spout;
class ref_params_ods extends ref_params {
const READER = [
"options" => self::READER_OPTIONS,
];
const READER_OPTIONS = [];
const WRITER = [
"options" => self::WRITER_OPTIONS,
"default_style" => self::STYLE,
];
const WRITER_OPTIONS = [];
const SHEET = [
"->setName" => ["string"],
"default_style" => self::STYLE,
"header_style" => self::STYLE,
"row_style" => self::STYLE,
];
}

View File

@ -0,0 +1,78 @@
<?php
namespace nulib\ext\spout;
class ref_params_xlsx extends ref_params {
const READER = [
"options" => self::READER_OPTIONS,
];
const READER_OPTIONS = [
"SHOULD_FORMAT_DATES" => "bool",
"SHOULD_PRESERVE_EMPTY_ROWS" => "bool",
];
const WRITER = [
"->setCreator" => ["string"],
"->setColumnWidth" => ["int", "int"],
"->setColumnWidthForRange" => ["int", "int", "int"],
"options" => self::WRITER_OPTIONS,
"default_style" => self::STYLE,
];
const WRITER_OPTIONS = [
"SHOULD_CREATE_NEW_SHEETS_AUTOMATICALLY " => "bool",
"SHOULD_USE_INLINE_STRINGS" => "bool",
"->setPageSetup" => [
"page_orientation" => "string",
"page_size" => "string",
"fit_to_height" => "bool",
"fit_to_width" => "bool",
],
"->setPageMargin" => [
"top" => "float",
"right" => "float",
"bottom" => "float",
"left" => "float",
"header" => "float",
"footer" => "float",
],
"->setHeaderFooter" => [
"odd_header" => "string",
"odd_footer" => "string",
"even_header" => "string",
"even_footer" => "string",
"different_odd_even" => "bool",
],
];
const SHEET = [
"->setName" => ["string"],
"->setColumnWidth" => ["int", "int"],
"->setColumnWidthForRange" => ["int", "int", "int"],
"view" => self::SHEET_VIEW,
"default_style" => self::STYLE,
"header_style" => self::STYLE,
"odd_style" => self::STYLE,
"even_style" => self::STYLE,
];
const SHEET_VIEW = [
"->setFreezeRow" => ["int"],
"->setFreezeColumn" => ["string"],
"->setZoomScale" => ["int"],
"->setShowFormulas" => ["bool"],
"->setShowGridLines" => ["bool"],
"->setShowRowColHeaders" => ["bool"],
"->setShowZeroes" => ["bool"],
"->setRightToLeft" => ["bool"],
"->setTabSelected" => ["bool"],
"->setShowOutlineSymbols" => ["bool"],
"->setDefaultGridColor" => ["bool"],
"->setView" => ["string"],
"->setTopLeftCell" => ["string"],
"->setColorId" => ["int"],
"->setZoomScaleNormal" => ["int"],
"->setZoomScalePageLayoutView" => ["int"],
"->setWorkbookViewId" => ["int"],
];
}