- Fri Oct 27, 2017 4:15 pm
#795993
I'm trying to use PHPExcel to read an excel file from a document in a variable with this trigger:
Code: Select all
But the code isn't working after ' $inputFileType = PHPExcel_IOFactory::identify($path); //identify type of file ' .... Is there something i did wrong ? I imported the 'Classes' folder from PHPExcel in /optif (isset(@@file_label) and @@file_label != '[]') {
$filename = json_decode(@@file_label)[0];
$fileId = json_decode(@@file)[0];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$d = new AppDocument();
$aFile = $d->Load($fileId);
$g = new G();
$path = PATH_DOCUMENT . $g->getPathFromUID(@@APPLICATION) . PATH_SEP .
$fileId .'_'. $aFile['DOC_VERSION'] .'.'. $ext;
@@path = $path;
@@require = require_once('/opt/Classes/PHPExcel.php');
@@require2 = require_once('/opt/Classes/PHPExcel/IOFactory.php');
$inputFileType = PHPExcel_IOFactory::identify($path); //identify type of file
$oReader = PHPExcel_IOFactory::createReader($inputFileType);
$oReader->setReadDataOnly(); //get data as plain text
@@oReader = $oReader;
try {
$oExcel = $oReader->load($path);
$aData = $oExcel->getActiveSheet()->toArray(null, true, true, true);
//print "<pre>"; var_dump($aData); die;
}
catch (Exception $e) {
$g->SendMessageText($e->getMessage(), 'ERROR');
};
if (count($aData) <= 1) {
$g->SendMessageText("File $filename contains no data", 'WARNING');
}
@@value = $aData[1]['A'];
}