how to excel to excel using

how to excel to excel using

kiran reddykiran reddy Posts: 3Questions: 1Answers: 0
table = $("#searchResultsDataGrid").DataTable({
        "aaData":response,
        "aoColumns": columns,
        "sScrollX": true,
        "sScrollY": true,
        responsive: false,
        "sDom": 'rt<"bottom"Bipl><"clear">',
        "bFilter": true,
        searching: true,
        "buttons": [{
            "className" : "hyperLinkBtn",
            "extend": "excelHtml5",
            "text": "Export to Excel",
            exportOptions: {

              columns:':not(.sorting_disabled)',
              format: {
                  body: function (data, row, column, node) {
                      data = $(data).text()==undefined || $(data).val().trim().length==0?$(data).val():$(data).text();
                      return data;
                  }
              }
          }
        }]

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi Kiran,

    You'll need to give us a clue I'm afraid, you're not saying what the problem is or what you want!? We're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kiran reddykiran reddy Posts: 3Questions: 1Answers: 0
    edited May 2018

    Hi Colin,
    after click on export to excel datatable are not downloading for this screen..

      body: function (data, row, column, node) {
                        body: function (data, row, column, node) {
                          data = $(data).text()==undefined || $(data).val().trim().length==0?$(data).val():$(data).text();
                          return data;
                          return data;
    

    in the these line data= body: function (data, row, column, node) {
    data = $(data).text()==undefined || $(data).val().trim().length==0?$(data).val:$(data).text(); in need to change..

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited May 2018

    Hi Kiran,

    If you're trying to modify the data to be exported, this example here will help, it's doing something similar. I'd suggest giving that a try and seeing where you get.

    Cheers,

    Colin

  • kiran reddykiran reddy Posts: 3Questions: 1Answers: 0

    Hi colin,
    i'm unable to see any example after clickinf here..
    in this line error i'm getting: data = $(data).text()==undefined || $(data).val().trim().length==0?$(data).val():$(data).text()

    for this condition data = $(data).text()==undefined is "false"
    for this condition $(data).val().trim().length==0? is "true"..

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I think your misunderstanding is that data is a jQuery node - it's not, it's just a string that contains that data. This example here may help - it's the same as above, but I noticed it wasn't linking to the correctt place before.

    Cheers,

    Colin

This discussion has been closed.