ajout de csv2xlsx

This commit is contained in:
Jephté Clain 2024-11-29 16:54:12 +04:00
parent 2cca077163
commit 714e528201
5 changed files with 68 additions and 16 deletions

View File

@ -12,7 +12,6 @@
</component> </component>
<component name="PhpIncludePathManager"> <component name="PhpIncludePathManager">
<include_path> <include_path>
<path value="$PROJECT_DIR$/vendor/nulib/php" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" /> <path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
<path value="$PROJECT_DIR$/vendor/nulib/phpss" /> <path value="$PROJECT_DIR$/vendor/nulib/phpss" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit" /> <path value="$PROJECT_DIR$/vendor/sebastian/code-unit" />
@ -59,6 +58,9 @@
<path value="$PROJECT_DIR$/vendor/nulib/tests" /> <path value="$PROJECT_DIR$/vendor/nulib/tests" />
<path value="$PROJECT_DIR$/vendor/psr/http-factory" /> <path value="$PROJECT_DIR$/vendor/psr/http-factory" />
<path value="$PROJECT_DIR$/vendor/composer" /> <path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/nulib/spout" />
<path value="$PROJECT_DIR$/vendor/nulib/php" />
<path value="$PROJECT_DIR$/vendor/nulib/spout" />
</include_path> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.4" /> <component name="PhpProjectSharedConfiguration" php_language_level="7.4" />

7
bin/csv2xlsx.php Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/php
<?php
require $_composer_autoload_path?? __DIR__.'/../vendor/autoload.php';
use nulib\tools\Csv2xlsxApp;
Csv2xlsxApp::run();

View File

@ -3,6 +3,18 @@
"type": "library", "type": "library",
"description": "espace de maturation pour les librairies", "description": "espace de maturation pour les librairies",
"repositories": [ "repositories": [
{
"type": "path",
"url": "../nulib"
},
{
"type": "path",
"url": "../nulib-spout"
},
{
"type": "path",
"url": "../nulib-phpss"
},
{ {
"type": "composer", "type": "composer",
"url": "https://repos.univ-reunion.fr/composer" "url": "https://repos.univ-reunion.fr/composer"

36
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ff7940a16992c5de7cd4078864ed2e95", "content-hash": "f226f4de27aa551752a2406afb1e90d7",
"packages": [], "packages": [],
"packages-dev": [ "packages-dev": [
{ {
@ -507,10 +507,10 @@
{ {
"name": "nulib/php", "name": "nulib/php",
"version": "dev-master", "version": "dev-master",
"source": { "dist": {
"type": "git", "type": "path",
"url": "https://git.univ-reunion.fr/sda-php/nulib.git", "url": "../nulib",
"reference": "3958b8f11d16d7a4c17feb415b9158425608112a" "reference": "876873d8fc537901bf8a0f4f1d679f93d0fbc0c9"
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
@ -547,14 +547,16 @@
} }
], ],
"description": "fonctions et classes essentielles", "description": "fonctions et classes essentielles",
"time": "2024-11-29T04:40:10+00:00" "transport-options": {
"relative": true
}
}, },
{ {
"name": "nulib/phpss", "name": "nulib/phpss",
"version": "dev-master", "version": "dev-master",
"source": { "dist": {
"type": "git", "type": "path",
"url": "https://git.univ-reunion.fr/sda-php/nulib-phpss.git", "url": "../nulib-phpss",
"reference": "df05afda07f5973e55db4568fac5a9659ab38e76" "reference": "df05afda07f5973e55db4568fac5a9659ab38e76"
}, },
"require": { "require": {
@ -589,15 +591,17 @@
} }
], ],
"description": "wrapper pour phpoffice/phpspreadsheet", "description": "wrapper pour phpoffice/phpspreadsheet",
"time": "2024-11-28T16:47:55+00:00" "transport-options": {
"relative": true
}
}, },
{ {
"name": "nulib/spout", "name": "nulib/spout",
"version": "dev-master", "version": "dev-master",
"source": { "dist": {
"type": "git", "type": "path",
"url": "https://git.univ-reunion.fr/sda-php/nulib-spout.git", "url": "../nulib-spout",
"reference": "d416e6799b9716d254e0cb7b31724e9e2f75d47d" "reference": "f9fd6b838eb95e0ab9274344174bbd6523464aa0"
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
@ -643,7 +647,9 @@
} }
], ],
"description": "wrapper pour openspout/openspout", "description": "wrapper pour openspout/openspout",
"time": "2024-11-28T17:36:37+00:00" "transport-options": {
"relative": true
}
}, },
{ {
"name": "nulib/tests", "name": "nulib/tests",

View File

@ -0,0 +1,25 @@
<?php
namespace nulib\tools;
use nulib\app\cli\Application;
use nulib\ext\tab\SsBuilder;
use nulib\ext\tab\SsReader;
use nulib\file;
use nulib\os\path;
use nulib\ValueException;
class Csv2xlsxApp extends Application {
private $args;
function main() {
$input = ValueException::check_null($this->args[0] ?? null);
$inputname = path::filename($input);
$output = path::ensure_ext($inputname, ".xlsx", ".csv");
$reader = SsReader::with($input);
$builder = SsBuilder::with($output);
$builder->writeAll($reader);
$builder->build();
$builder->copyTo(file::writer($output), true);
}
}