catamphetamine / read-excel-file

Read *.xlsx files in a browser or Node.js. Parse to JSON with a strict schema.
https://catamphetamine.gitlab.io/read-excel-file/
MIT License
301 stars 52 forks source link

rowIndex is missing in successful rows #77

Closed ramya-sc closed 4 years ago

ramya-sc commented 4 years ago

Hi, [sample_sheet.xlsx](https://github.com/catamphetamine/read-excel-file/files/4373534/sample_sheet.xlsx) , readXlsxFile(this.fileToUpload, { schema, transformData(data, ) { // read the excel sheet from row 1 for (let i = 1; i < data.length; i++) { let result = data[i] if (result) { results.push(result) } } return results; // return data.filter(row => row.filter(column => column !== null).length > 0) } }).then(({ rows, errors, }) => { console.log(rows) } image

Is it possible to add row_Index to above rows (attached image) ? ,

Like how we are getting row_Index in errors [ image ]

using : "read-excel-file": "^4.0.6",

catamphetamine commented 4 years ago

Hi. Why would you want to have row index in rows? The answer is short: anything is possible, but such feature doesn't make any sense.

ramya-sc commented 4 years ago

Because, Assume, below are the successful rows what I am getting from excel , let it be array1 , image

and I formatted the errors arrays something like below according to my requirement, let it be array2, image

and I need to form a newArray like below by looping through array1 and array2

[ {row: 1, firstName: null, lastName: null, phoneNo: 123, emailId: null }, {row: 2, firstName: "Ramya", lastName: "f", phoneNo: null, emailId: "ramy" }, {row: 3, firstName: null, lastName: "k" , phoneNo: null, emailId: null }, {row :4 , firstName: "Divya", lastName: "h", phoneNo: 1234567890, emailId: "divya@gmail.com" }, {row :5 , firstName: "Jhon" , lastName: null, phoneNo: null, emailId: null }, { row:6 , firstName: null, lastName: "a", phoneNo: null, emailId: null } ]

As, there is no key called row in array1 , I am facing difficultly to loop an array1 and array2, and not only in the above scenario , If rowIndex is available, then we can perform any further operation on rows and errors. So, I am requesting you to please add rowIndex for the successful rows. Thanks.

catamphetamine commented 4 years ago

So, I am requesting you to please add rowIndex for the successful rows.

No features would be added. But, you can fork the project and add any features and then release it as another package.

catamphetamine commented 4 years ago

I'll close this one.