A
A
Albertic0722021-04-21 16:11:49
JavaScript
Albertic072, 2021-04-21 16:11:49

Why does the encoding crash when forming a table in excel?

6080247ac96a7217242716.png

<a href="#" id="tableName" onclick="downloadFile()">Импорт данных в Excel</a>
        <br /><br />
        <div id="tableWrap">
            <table width="100%" border="1" cellpadding="3px" style="font-size: 12px; border-collapse: collapse; border: 1px solid gray;">
                <tr> 
                    <th>Наименование</th>
                    <th>Количество</th>
                    <th>Стоимость</th>
                </tr>
              </table>
        </div>

<script type="text/javascript">
    function downloadFile(){
        var url='data:application/vnd.ms-excel,' + encodeURIComponent($('#tableWrap').html())
        location.href=url
        return false
    }
</script>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question