How to export datatable data in excel file in magento 2

How to export datatable data in excel file in magento 2

Ramkumar KRamkumar K Posts: 1Questions: 1Answers: 0
edited April 13 in DataTables
<table id="example" class="display" style="width:100%">
                <th>Start date</th>
                <td>Tiger Nixon</td>
                <td>System Architect</td>
                <td>Garrett Winters</td>
                <td>Ashton Cox</td>
                <td>Junior Technical Author</td>
                <td>San Francisco</td>
                <td>Cedric Kelly</td>
                <td>Senior Javascript Developer</td>
                <td>Airi Satou</td>

            ], function($){
                $(document).ready(function() {

                        dom: 'Bfrtip',
                        buttons: [
                                extend: 'excelHtml5',
                                exportOptions: {
                                    columns: [ 0, 1, 2, 3 ]
                                extend: 'csvHtml5',
                                exportOptions: {
                                    columns: [ 0, 1, 2, 3 ]

There is no error in console.

Result: CSV button is visible and working. But Excel button is not visible.

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.


  • colincolin Posts: 12,098Questions: 0Answers: 2,054

    The flash button isn't needed any more, and it doesn't look like you're including the CSS files. If you look at this example here, ensure you have the necessary files listed on the Javascript and CSS tabs beneath the table.


  • shaistamikeshaistamike Posts: 1Questions: 0Answers: 0

    Hi, I have done some research on it few months earlier and find out this... It works for me and I hope it will work for you too.

    <exportButton class="Magento\Ui\Component\ExportButton">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="options" xsi:type="array">
    <item name="cvs" xsi:type="array">
    <item name="value" xsi:type="string">csv</item>
    <item name="label" xsi:type="string" translate="true">CSV</item>
    <item name="url" xsi:type="string">mui/export/gridToCsv</item>
    <item name="xml" xsi:type="array">
    <item name="value" xsi:type="string">xml</item>
    <item name="label" xsi:type="string" translate="true">Excel XML</item>
    <item name="url" xsi:type="string">mui/export/gridToXml</item>
    <item name="xls" xsi:type="array">
    <item name="value" xsi:type="string">xls</item>
    <item name="label" xsi:type="string" translate="true">Excel XLS</item>
    <item name="url" xsi:type="string">{{module}}/export/gridToXls</item>

    I recommend woocommerce as it is more friendly then magento. I have personally did some research on Magento vs WooCommerce and yes woocomerce did win for me... I believe everyone has it's own preference.

Sign In or Register to comment.