Retrieving specific rows from XLS
I’m trying to receive data from specific rows of an XLSX file. I’m currently using the XLSX library. What I have in my excel file is something like this:
First Name | Second Name | Age John | Smith | 18 Jane | Doe | 20 ...
With this code
let workbook = XLSX.readFile(path, { sheetRows: 2 } let sheetsList = workbook.SheetNames return XLSX.utils.sheet_to_json(workbook.Sheets[sheetsList[1]], { header: ['Header 1', 'Header 2'] });
I am able to access only the first row, the output was:
[ { 'Header 1': 'First Name', 'Header 2': 'Last Name' }, { 'Header 1': 'John', 'Header 2': 'Smith'}, { 'Header 1': 'Jane', 'Header 2': 'Doe' }, ]
Where do I insert in my code such that I am able to receive the First Name and Age?
If my header includes 2 strings, then it’ll return the first 2 columns. How do I obtain, for example, the first and the third column?