I am using the node.js package xlsx to access an xlsx file using the following code:
const XLSX = require("xlsx")
wbInput.addEventListener("change", (evt) => {
if (wbInput.files.length === 0)
return;
actOnXLSX(wbInput.files[0]);
}, false);
async function actOnXLSX (file) {
const fileReader = new FileReader();
const data = await new Promise((resolve, reject) => {
fileReader.onload = () => {
resolve(fileReader.result);
};
fileReader.onerror = reject;
fileReader.readAsArrayBuffer(file);
})
.finally(() => {
fileReader.onerror = fileReader.onload = null;
});
const workbook = XLSX.read(data);
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
console.log(worksheet)
var columnA = []
for (let z in worksheet) {
if(z.toString()[0] === 'A'){
columnA.push(worksheet[z].v);
}
}
console.log(columnA);
for (let i= 1; i < columnA.length; i++) {
console.log(columnA[i], i)
}
}
This works fine for when all the cells between the first and the end cell contain data, but when there is an empty cell the array skips it instead of storing it as an empty entry. Is it possible for it to store when there are empty codes? I will be using i to simultaneously write to a spreadsheet using another function so the array always needs to remain true to the spreadsheet it is reading.