0

const input = document.getElementById("input")
input.addEventListener("change", (event) => {
    selectedFile = event.target.files[0];

})

let data=[{
    "name":"jayanth",
    "data":"scd",
    "abc":"sdef"
}]

const excelFunction = (fileReader) =>{
    
            XLSX.utils.json_to_sheet(data,'out.xlsx');
            myFile.readAsBinaryString(selectedFile);
            myFile.onload = (event)=>{
                let data = event.target.result;
                let workbook = XLSX.read(data,{type:"binary"});
                workbook.SheetNames.forEach(sheet => {
                    let rowObject = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheet]);
                    document.getElementById("jsondata").innerHTML = JSON.stringify(rowObject,undefined,4)
         });
        }
    button.setAttribute("style","display:none")
    input.setAttribute("style","display:none")
        
}//
const  repeatExcelFunc = (fileReader)=>{
     setInterval( function() {excelFunction(fileReader)},1000)
}
const fileReader = new FileReader();
let button = document.getElementById('button')
button.addEventListener("click",function(){
    repeatExcelFunc(fileReader)

});

hey I have a page that uses and picks xlsx file from shared folder and then I display it on the browser with html. I have managed to do that with JS-XLSX library and now I have the data in the web page. I want to be able to update the web page when there is a change in the xlsx so I used setIntervals to check for changes in the xlsx file content but when I save the content change in the xlsx file, the fileReader.onLoad event stop triggering... anyone knows how to fix it? already tried changing event type and using another library but ended up in the same problem my code:

0 Answers0