-2

I would like to know how can i export the contents of an Observable Array to an excel file, it could csv file as well. once my array is filled.. i enable a button on the screen when i click on it, i want to export that from the array.

Here is my code:

self.obtenerEmpleadosAlerta = function () {
var idNomina = $("#IDCalendarioNomina").val();
if (idNomina != "") {
    var url = pathApi + "apinomina/obtenerListaEmpleadosAlerta/" + idNomina;
    self.listaEmpleadosAlerta.removeAll();
    disableBottonForm("frmCalendarioNomina", "btnConsultar", "lGenerarNomina");
    $.getJSON(url)
        .done(function (data) {

            if (data["estatus"]) {

                enableBottonForm("frmCalendarioNomina", "btnAlertaEmpleados", "lGenerarNomina");

                $.each(data["resultado"], function (key, item) {

                    item.Fecha = toShortDateString(item.Fecha);
                    self.listaEmpleadosAlerta.push(item);

                });
            } else {
                mostrarToastr(data["mensaje"], "E");
            }

        }).fail(function (d) {
            enableBottonForm("frmCalendarioNomina", "btnConsultar", "lGenerarNomina");
            mostrarToastr(d.responseText, "E");
        });
}

}

1 Answers1

0

you could use http://danml.com/download.html to download file from javascript

for exmaple

 download(data, 'Export.csv', 'application/csv');

where data will be your observable array content as JSON and file name and file type.

jjj
  • 1,136
  • 3
  • 18
  • 28