- Thu May 23, 2019 1:41 pm
#824570
Hello everyone,
I have a process which includes the uploading of a .xlsx file to feed the variables inside a grid. This grid has a total of eight columns and must be able to accept a total of 2,500 lines. The issue is that this creates a total of 20,000 values inside the grid and trying to uploading it, while successful, takes between four and five minutes.
Is there a way we can reduce the time BPM takes to upload this large file (31KB or 32KB)?
This is the code the trigger uses to upload the document
I have a process which includes the uploading of a .xlsx file to feed the variables inside a grid. This grid has a total of eight columns and must be able to accept a total of 2,500 lines. The issue is that this creates a total of 20,000 values inside the grid and trying to uploading it, while successful, takes between four and five minutes.
Is there a way we can reduce the time BPM takes to upload this large file (31KB or 32KB)?
This is the code the trigger uses to upload the document
Code: Select all
require_once("/bpm/processmaker/shared/PhpSpreadsheet-develop/src/PhpSpreadsheet/Spreadsheet.php");
function getFilePath($appUid, $appDocUid) {
$appDocument = new AppDocument();
$result = $appDocument->load($appDocUid);
$ext = pathinfo($result["APP_DOC_FILENAME"], PATHINFO_EXTENSION);
$path = PATH_DOCUMENT
. G::getPathFromUID($appUid)
. PATH_SEP . $appDocUid
. '_'
. $result['DOC_VERSION']
. '.'
. $ext;
return $path;
}
function getDataUsingPhpSpreadsheet($path) {
$spreadsheet = PhpOffice\PhpSpreadsheet\IOFactory::load($path);
$sheet = $spreadsheet->getActiveSheet();
$data = $sheet->toArray(null, true, true, true, true, true, true, true, true);
return $data;
}
function getData($appUid, $appDocUid) {
$path = getFilePath($appUid, $appDocUid);
$data = getDataUsingPhpSpreadsheet($path);
//remove headers row
array_shift($data);
$clients = [];
foreach ($data as $key => $value) {
$clients[$key + 1] = [
'customerNumber' => $value['A'],
'creditMemo' => $value['B'],
'paymentNumber' => $value['C'],
'invoiceDeduction' => $value['D'],
'amountinCurrency' => $value['E'],
'usdConversion' => $value['F'],
'amountRemaining' => $value['G'],
'comments' => $value['H'],
];
}
return $clients;
}
//main
$appUid = @@APPLICATION;
$index = @@INDEX;
$clientsFile = @@clientsFile;
//set to UID of form where file is uploaded
$dynUid = '6392997235b479ad6807a88026307315';
//validations
$clientsFile = json_decode($clientsFile);
//Set the path where the library is located
$file1 = '/bpm/processmaker/shared/PhpSpreadsheet-develop/src/Bootstrap.php';
if (empty($clientsFile[0]) || !file_exists($file1)) {
PMFRedirectToStep($appUid, $index, 'DYNAFORM', $dynUid);
}
//process
require_once $file1;
$clients = getData($appUid, $clientsFile[0]);
@=clientsList = $clients;