Created
March 21, 2018 05:17
-
-
Save gogl92/ae911e06aa2c3e8f8af7c4a43a5e0706 to your computer and use it in GitHub Desktop.
Read and Show a File with Javascript in Yii2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$this->registerJsFile('https://unpkg.com/xlsx/dist/xlsx.full.min.js'); | |
$this->registerJs('$(\'#input-excel\').change(function(e){ | |
var reader = new FileReader(); | |
reader.readAsArrayBuffer(e.target.files[0]); | |
reader.onload = function(e) { | |
var data = new Uint8Array(reader.result); | |
var wb = XLSX.read(data,{type:\'array\'}); | |
var htmlstr = XLSX.write(wb,{sheet:"Ejemplo Semanal", type:\'binary\',bookType:\'html\'}); | |
$(\'#wrapper\')[0].innerHTML += htmlstr; | |
} | |
});') | |
?> | |
<div id="wrapper"> | |
<input type="file" id="input-excel" /> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment