problems when recording an excel with SheetJS

0

I have the following script, which allows the user (client) to select an excel from their disk drive, using SheetJs and angularJS

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.10.8/xlsx.full.min.js" ></script>

    <script>
        (function () {
            var app = angular.module('myApp', []);
            app.controller('MyController', ['$scope', myController]);

            var excelJsonObj = [];
            function myController($scope) {
                $scope.uploadExcel = function () {
                    var myFile = document.getElementById('file');
                    var input = myFile;
                    var reader = new FileReader();
                    reader.onload = function () {

                        var fileData = reader.result;
                        var workbook = XLSX.read(fileData, { type: 'binary' });

                        // aca se deberia crear el archivo excel nuevo con el nombre 'c:\test.xlsx'
                        var wbOut = XLSX.write(workbook, { booktype: 'xlsx', type: 'binary' });
                        saveAs(new Blob([s2ab(wbout)], { type: "application/octet-stream" }), 'c:\test.xlsx');

                    };
                    reader.readAsBinaryString(input.files[0]);
                };
            }

        })();

        function s2ab(s) {
            var buf = new ArrayBuffer(s.length); //convert s to arrayBuffer
            var view = new Uint8Array(buf);  //create uint8array as viewer
            for (var i = 0; i < s.length; i++) view[i] = s.charCodeAt(i) & 0xFF; //convert to octet
            return buf;
        }

        $(document).ready(function () {
            $("#cargaMasivaTrigger").on("click", function () {
                $("#file").val(null);
                $("#file").trigger("click");
            });

            $("#file").on("change", function () {
                $("#contenedor_carga").show();
                $("#btnCargaMasiva").trigger("click");
                $.ajax({
                    type: 'POST',
                    url: 'FichaEST.aspx/DropSession',
                    data: "{}",
                    dataType: 'json',
                    contentType: 'application/json',
                    async: true,
                    success: function (response) {
                    },
                    error: function (xhr) {
                        console.log(xhr.responseText);
                    },
                    complete: function () {

                    }
                });

            });
        });


</script>

My problem is that the file is not recorded in the route that I am indicating. Can someone help me see where I'm making the mistake?

in the console does not show me execution errors.

Greetings and thanks

    
asked by Luis Gabriel Fabres 21.11.2018 в 21:49
source

0 answers