converting csv to xlsx

This commit is contained in:
schrom01
2023-09-25 22:22:50 +02:00
parent 4f8ea5704e
commit 867f2589c7
4 changed files with 1056 additions and 53 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/SimpleXLSX.php';
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/SimpleXLSXGen.php';
function read_xls_file($filename){
$fileContent = [];
if ($xlsx = SimpleXLSX::parse($filename)) {
$fileContent = ($xlsx->rows());
} else {
echo SimpleXLSX::parseError();
}
return $fileContent;
}
function write_xlsxFile($filename, $data) {
$xlsx = SimpleXLSXGen::fromArray($data);
$xlsx->saveAs($filename);
}
function download_xlsxFile($data) {
$xlsxArray = read_xls_file($_SERVER['DOCUMENT_ROOT'] ."/data/data.xlsx");
foreach ($data as $row) {
array_push($xlsxArray, $row);
}
$xlsx = SimpleXLSXGen::fromArray($xlsxArray);
$xlsx->downloadAs("data.xlsx");
}