converting csv to xlsx

This commit is contained in:
schrom01 2023-09-25 20:18:24 +02:00
parent 278a926ddb
commit 9a59a4116e
1 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,6 @@
<?php <?php
include "zefixAPI.php"; include "zefixAPI.php";
include 'PHPExcel/IOFactory.php';
$maxExecutionTime = 480; $maxExecutionTime = 480;
$taskDir = 'tasks'; $taskDir = 'tasks';
@ -51,6 +52,20 @@ function sendEmail($emailAddress, $filename)
echo "sending ".$filename." too ".$emailAddress; echo "sending ".$filename." too ".$emailAddress;
} }
// Stop executing bevore reaching PHP Max Execution Time // Stop executing bevore reaching PHP Max Execution Time
function convertcsvToXlsx(string $csvFile, string $xslxFile)
{
$objReader = PHPExcel_IOFactory::createReader('CSV');
// If the files uses a delimiter other than a comma (e.g. a tab), then tell the reader
$objReader->setDelimiter("\t");
// If the files uses an encoding other than UTF-8 or ASCII, then tell the reader
$objReader->setInputEncoding('UTF-16LE');
$objPHPExcel = $objReader->load($csvFile);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save($xslxFile);
}
while($latesEndTime - time() > 60){ while($latesEndTime - time() > 60){
// If the directory for Tasks is already created // If the directory for Tasks is already created
if(is_dir($taskDir)) { if(is_dir($taskDir)) {