js Paste Excel Table

amazing simple stuff that save developer lifes

HTML

<textarea class='excelPaste' id='excel'></textarea>

CSS

.excelPaste{  
border-top-style:dotted;
border-right-style:solid;
border-bottom-style:dotted;
border-left-style:solid;
   
}

@keyframes excelAnim{
    0% {
 border-top-style: solid !important;
    }
    50% {
         border-top-style:solid;
    }
    100% {
        background-color:rgba(255,0,0,0.9);
    }
}


.excelPaste:hover{
    animation-name: excelAnim;
    animation-duration: 1s;
    animation-iteration-count: 4;
    animation-direction: alternate;
    animation-timing-function: ease-in-out;
}

JavaScript

dojo.byId('excel').onpaste=function(e){
    dojo.byId('excel').value='';
setTimeout(parseExcelData,10);
}
    
    var excelData=new Array();
    function parseExcelData(){
        excelData=new Array();
                var raw=dojo.byId('excel').value.trim();
        var rows=raw.split('\n');
        var firstRowLen=rows[0].split('\t').length;
        for (var i in rows){
         
           var cols=rows[i].split('\t');
              console.debug(rows[i]);
                    console.debug(cols);
            if (cols.length==1){
                
            cols=rows[i].split(' ');
                            console.debug(cols);
              //formato file scuole
              if (cols[0].match("^000")){
                  
              }
        }
            if(cols.length==firstRowLen){
                excelData.push(cols);
            }
        }
       //   dojo.byId('excel').value='';
        console.debug(excelData);
    }