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 name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/nulib/php" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
<path value="$PROJECT_DIR$/vendor/nulib/phpss" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit" />
@ -59,6 +58,9 @@
<path value="$PROJECT_DIR$/vendor/nulib/tests" />
<path value="$PROJECT_DIR$/vendor/psr/http-factory" />
<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>
</component>
<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",
"description": "espace de maturation pour les librairies",
"repositories": [
{
"type": "path",
"url": "../nulib"
},
{
"type": "path",
"url": "../nulib-spout"
},
{
"type": "path",
"url": "../nulib-phpss"
},
{
"type": "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",
"This file is @generated automatically"
],
"content-hash": "ff7940a16992c5de7cd4078864ed2e95",
"content-hash": "f226f4de27aa551752a2406afb1e90d7",
"packages": [],
"packages-dev": [
{
@ -507,10 +507,10 @@
{
"name": "nulib/php",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://git.univ-reunion.fr/sda-php/nulib.git",
"reference": "3958b8f11d16d7a4c17feb415b9158425608112a"
"dist": {
"type": "path",
"url": "../nulib",
"reference": "876873d8fc537901bf8a0f4f1d679f93d0fbc0c9"
},
"require": {
"ext-json": "*",
@ -547,14 +547,16 @@
}
],
"description": "fonctions et classes essentielles",
"time": "2024-11-29T04:40:10+00:00"
"transport-options": {
"relative": true
}
},
{
"name": "nulib/phpss",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://git.univ-reunion.fr/sda-php/nulib-phpss.git",
"dist": {
"type": "path",
"url": "../nulib-phpss",
"reference": "df05afda07f5973e55db4568fac5a9659ab38e76"
},
"require": {
@ -589,15 +591,17 @@
}
],
"description": "wrapper pour phpoffice/phpspreadsheet",
"time": "2024-11-28T16:47:55+00:00"
"transport-options": {
"relative": true
}
},
{
"name": "nulib/spout",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://git.univ-reunion.fr/sda-php/nulib-spout.git",
"reference": "d416e6799b9716d254e0cb7b31724e9e2f75d47d"
"dist": {
"type": "path",
"url": "../nulib-spout",
"reference": "f9fd6b838eb95e0ab9274344174bbd6523464aa0"
},
"require": {
"ext-dom": "*",
@ -643,7 +647,9 @@
}
],
"description": "wrapper pour openspout/openspout",
"time": "2024-11-28T17:36:37+00:00"
"transport-options": {
"relative": true
}
},
{
"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);
}
}