Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82616

How to get the Excel attached to Email?

$
0
0

I want to send email with attached Excel created from Datatables buttons.
I created controller to send email.
and created datatables to export excel
I do not know how to get the excel in ajax to send to controller.
this is my code but it is not working

$('#example-table').DataTable({
dom: 'Blfrtip',

        buttons: [
            {
                extend: 'excelHtml5',
                title: 'Data',
                text: 'Export To Excel',
                exportOptions: {
                    format: {
                        body: function (inner, rowidx, colidx, node) {
                            if ($(node).children("input").length > 0) {
                                return $(node).children("input").first().val();
                            } else {
                                return inner;
                            }
                        }
                    }


                },

                action: function (e, dt, node, config) {

                   //var files = $.fn.dataTable.ext.buttons.excelHtml5.action.call(this, e, dt, node, config);

                    var table = $('#example-table').DataTable();

                    var data = table.buttons.exportData();
                    var files = $("#fileUploader").get(0).files[0];
                    var url = "/test/SendEmail";
                    formData = new FormData();
                    formData.append("fileUploader", files);

                    jQuery.ajax({
                        type: 'POST',
                        url: url,
                        data: formData,
                        dataType: 'xlsx',
                        cache: false,
                        contentType: false,
                        processData: false,

                    });


                }
            },              

        ]

Viewing all articles
Browse latest Browse all 82616

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>