I am exporting a HTML table to Excel but it is giving me error like:
"The file you are trying to open is in the different format than the specified by the file extension..."
I tried different extension like .xlsx also still giving same error. Below is my jQuery code:
$(document).ready(function() {
      $("#btnExport").click(function(e) {
        e.preventDefault();
        //getting data from our table
        var data_type = 'data:application/vnd.ms-excel';
        var table_div = document.getElementById('table_wrapper');
        var table_html = table_div.outerHTML.replace(/ /g, '%20');
        var a = document.createElement('a');
        a.href = data_type + ', ' + table_html;
        a.download = 'DSR_Report_' + Math.floor((Math.random() * 9999999) + 1000000) + '.xls';
        a.click();
      });
    });
And the HTML table I am exporting to Excel:
<div id="table_wrapper">
    <table border="1" id="list" class="table-style-two">
        <tbody>
            <tr>
                <th>NAME</th>
                <th>PROJECT_NAME</th>
                <th>DESCRIPTION</th>
                <th>HOURS</th>
                <th>START_DATE</th>
                <th>CURRENT_PROJECT_STATUS</th>
                <th>WORK_FOR_TOMORROW</th>
                <th>TOMORROW_WORK_STATUS</th>
                <th>COMMENTS</th>
                <th>VIEW_POINT_TICKET</th>
                <th>DSR_CURRENT_DATE</th>
            </tr>
            <tr id="417">
                <td>Anupam Bhattacharjee</td>
                <td>Cybage</td>
                <td>Daily standup meeting</td>
                <td>0.5</td>
                <td>2015-11-20</td>
                <td>Complete</td>
                <td>NA</td>
                <td>NA</td>
                <td>NA</td>
                <td>NA</td>
                <td>2015-11-20</td>
            </tr>
            <tr id="418">
                <td>Anupam Bhattacharjee</td>
                <td>Tomford</td>
                <td>TF3799-28303 - Assisted Pavan in resolving the issue via skype.Fixed issue in Tomford mule where the OrderShipment was erring out.</td>
                <td>1.5</td>
                <td>2015-11-19</td>
                <td>Complete</td>
                <td>NA</td>
                <td>NA</td>
                <td>NA</td>
                <td>WO3799</td>
                <td>2015-11-20</td>
            </tr>
        </tbody>
    </table>
</div>
EDIT : It is not duplicate of this question as in that question user is not able to export but i am able to export and my exported excel file is having issue.
 
     
     
     
     
    