    function getJsonFromUploadExcel(fileInputId, requiredTemplateHeading, maxRecords){
        
        let promise=new Promise(function(resolve, failure){
            let regex=/^([a-zA-Z0-9\s_\\.\-\\():])+(.xlsx)$/;
            let filePath=$("#"+fileInputId).val().toLowerCase();
            let fileDetails=$("#"+fileInputId)[0].files[0];
            
            let validateTemplateHeading=((csv_string_data, requiredTemplateHeading)=>{
                let stringCSVArray=csv_string_data.split(",");
                let index=0;
                while(index < requiredTemplateHeading.length){
                    if((requiredTemplateHeading[index])!=(stringCSVArray[index])){
                        return false;
                    }
                    index++;
                }
                return true;
            });
            
            if(regex.test(filePath)){               /*checks whether the file is a valid excel file*/ 
                let xlsxflag=false;                 /*Flag for checking whether excel is .xls formate or .xlsx formate*/
                if(filePath.indexOf(".xlsx") > 0){
                    xlsxflag = true;
                }
                /* check whether browser supports HTML5*/
                if(typeof(FileReader)!="undefined"){
                    let reader =new FileReader();
                    reader.onload=function (e){
                        let data=e.target.result;
                        let workbook;
                        /*Converts the excel data in to object*/
                        if(xlsxflag){
                            workbook =XLSX.read(data, {
                                type:'binary'
                            });
                        }else{
                            workbook =XLS.read(data,{
                                type:'binary'
                            })
                        }
                        /*Gets all the sheetnames of excel in to a variable*/
                        let sheet_name_list = workbook.SheetNames;
                        let cnt = 0; /*This is used for restricting the script to consider only first sheet of excel*/
                        sheet_name_list.forEach(function(y){
                            let exceljson;
                            if(xlsxflag){
                                exceljson= XLSX.utils.sheet_to_json(workbook.Sheets[y]);
                            }else{
                                exceljson = XLS.utils.sheet_to_row_object_array(workbook.Sheets[y])
                            }
                            // 
                            let csv_string_data=XLSX.utils.sheet_to_csv(workbook.Sheets[y]);
                            if(exceljson.length > 0 && cnt ===0){
                                if(validateTemplateHeading(csv_string_data, requiredTemplateHeading)){ // heading part in template
                                    if(exceljson.length < maxRecords){  // max records allowed
                                        exceljson=JSON.parse(JSON.stringify(exceljson).replace(/"\s+|\s+"/g,'"'));// remove empty spaces from string and reAppending in same  var exceljson
                                        resolve(exceljson);  // return excel json
                                    }else{
                                        alert("Total site Details are"+exceljson.length+", Site-Details Max Limit"+maxRecords);
                                    }
                                }else{
                                    alert("Invalid Template, Please download the Template from  link & fill data and try agian. ");
                                }
                                
                            }else if(exceljson.length <= 0 && cnt === 0){
                                alert("Empty Excel uploaded");
                                cnt++;
                            }
                        })
                    }
                    if(xlsxflag){
                        /*If excel file is .xlsx extension than creates a Array Buffer from excel*/
                        reader.readAsArrayBuffer(fileDetails);
                    }else{
                        reader.readAsBinaryString(fileDetails);
                    }
                }else{
                    alert("Sorry! Your browser does not support HTML5!");
                }
            }else{
                alert("Please upload a valid Excel file! or Only file formate(.xlsx) supported");
            }
        });
        return promise;
    }
    