converting csv to xlsx
This commit is contained in:
parent
278a926ddb
commit
9a59a4116e
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
include "zefixAPI.php";
|
||||
include 'PHPExcel/IOFactory.php';
|
||||
|
||||
$maxExecutionTime = 480;
|
||||
$taskDir = 'tasks';
|
||||
|
@ -51,6 +52,20 @@ function sendEmail($emailAddress, $filename)
|
|||
echo "sending ".$filename." too ".$emailAddress;
|
||||
}
|
||||
// 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){
|
||||
// If the directory for Tasks is already created
|
||||
if(is_dir($taskDir)) {
|
||||
|
|
Loading…
Reference in New Issue