nur-ture/src_glue/tools/Csv2xlsxApp.php

26 lines
618 B
PHP
Raw Normal View History

2024-11-29 16:54:12 +04:00
<?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);
}
}