I have cast names from my cypress test and I have saved them in a text file named 'name.txt' which is in my project root directory. I want to copy all the text from my 'name.txt' file and paste it in excel file 'qaautomation.xlsx' sheet 'Series Cast' and column 'Name'. I want to write the code in cypress/plugins/index.js for copying the text from name.txt file to 'qaautomation.xlsx' file using xlsx library. But I have no idea how to copy text from excel file and paste in particular sheet and particular column of excel file
First install the XLXS library in your editor.
npm install xlsx
And then read your .txt file with `XLSX.readFile() and append the data of text file to excel sheet. You can obviously create the custom column.
if(typeof require !== 'undefined') XLSX = require('xlsx');
const file = `scripts/output.xls`;
const txt = XLSX.readFile('scripts/input.txt');
XLSX.writeFile(txt, "scripts/output.xls")
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.