function loadExcelResultsCorrida(trReference, TypeAdd){
    let inputFile = $("<input type='file' id='inputFile' accept='.xlsx, .xls' style='display:none;'>");
    $("body").append(inputFile);
    inputFile.click();
    inputFile.change(function(){
        let file = this.files[0];
        let reader = new FileReader();
        reader.readAsBinaryString(file);
        reader.onload = function(){
            let data = reader.result;
            let workbook = XLSX.read(data, {type: 'binary'});
            let sheet_name_list = workbook.SheetNames;
            let sheet = workbook.Sheets[sheet_name_list[0]];
            let dataExcel = XLSX.utils.sheet_to_json(sheet, {header:1, range:1});
            dataExcel.forEach(function(row){
                addFilaTable(trReference, TypeAdd, row);
            });
        }
    }
    );
            
}

function loadExcelResultsEP15(){
    let inputFile = $("<input type='file' id='inputFile' accept='.xlsx, .xls' style='display:none;'>");
    $("body").append(inputFile);
    inputFile.click();
    inputFile.change(function(){
        let file = this.files[0];
        let reader = new FileReader();
        reader.readAsBinaryString(file);
        reader.onload = function(){
            let data = reader.result;
            let workbook = XLSX.read(data, {type: 'binary'});
            let sheet_name_list = workbook.SheetNames;
            let sheet = workbook.Sheets[sheet_name_list[0]];
            let dataExcel = XLSX.utils.sheet_to_json(sheet, {header:1, range:2});
            loadEP15Results(dataExcel);
        }
    }
    );
}

function loadEP15Results(excelData){
    let numLevels = $(".levelData").length;
    for(let level = 1; level <= numLevels; level++){
        for(let corrida = 1; corrida <= 5; corrida++){
            for(let repeticion = 1; repeticion <= 5; repeticion++){
                let value = excelData[corrida-1][(level-1)*5 + repeticion-1];
                let input = $("#level_"+level+"_corrida_"+corrida+"_rep_"+repeticion);
                input.val(value);
                let fecha = $("#level_"+level+"_corrida_"+corrida+"_fecha");
                let fechaValue = moment().format("YYYY/MM/DD HH:mm:ss");
                fecha.val(fechaValue);
            }
        }
    }
}
