Code: Select all

```
const fs = require("fs");
const ExcelJS = require('exceljs');
const path = require('path');
async function jobArrived(s, flowElement, job) {
//get data from job
let jobName = await job.getName(includeExtension=false);
let PDFStamp = await job.getPrivateData("PDFTime");
let NESTStamp = await job.getPrivateData("NESTTime");
//convert seconds to HH:MM:SS for excel
function secondsToTimePDF(e) {
h = Math.floor(e / 3600).toString().padStart(2, '0'),
m = Math.floor(e % 3600 / 60).toString().padStart(2, '0'),
s = Math.floor(e % 60).toString().padStart(2, '0');
return h + ':' + m + ':' + s;
}
function secondsToTimeNEST(e) {
h = Math.floor(e / 3600).toString().padStart(2, '0'),
m = Math.floor(e % 3600 / 60).toString().padStart(2, '0'),
s = Math.floor(e % 60).toString().padStart(2, '0');
return h + ':' + m + ':' + s;
}
let asd = secondsToTimePDF(PDFStamp) ;
let xyz = secondsToTimeNEST(NESTStamp);
//location of excel file
let filePath ="S:/1-AUTO PP/ERROR/Data.xlsx"
// excel stuff
const workbook = new ExcelJS.Workbook()
workbook.xlsx.readFile(filePath).then(async function () {
let worksheet = workbook.getWorksheet('Time counter')
worksheet.addRow([jobName, asd, xyz]);
await workbook.xlsx.writeFile(filePath)
})
await job.sendToNull();
}
```