Below is my code Ws -Contains redundant data while wsRemDup -contains data after removing the redundant/duplicate data. wsRemDup is an array of JSON.
I want to overwrite my ws sheets data with wsRemDup. I googled to find a way but most of the stuff showed how to append instead of overwriting it. How can I proceed?
ws = XLSX.utils.sheet_add_json(ws, ticketNameArr,{origin:-1, skipHeader:true});
//Contains unique ticket name and their other fields
wsRemDup=removeDuplicate(ws)
console.log(wsRemDup)
XLSX.writeFile(wb, 'DailyTicketSatus.xlsx')
respond.render('index', { "ticketNameArr": ticketNameArr });
You should be able to overwrite the sheet on your original workbook like so:
const excelFile = "tickets.xlsx";
const sheetName = "Sheet1" // <-- Change to the actual sheet name.
const workbook = XLSX.readFile(excelFile);
const ws = workbook.Sheets[sheetName];
let sheetJson = removeDuplicate(ws);
// Overwrite worksheet
workbook.Sheets[sheetName] = XLSX.utils.json_to_sheet(sheetJson);
XLSX.writeFile(workbook, excelFile);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.