Export a Excel *.xls instead *.cvs

Hello,

I am trying to export a xls file instead cvs and I am not able to do it. Could someone help me with this issue?

Thqnk you very much.

Albaro

Tadabase can only export to CSV, but if you’re looking for a external solution to export all visible records to an Excel file I can show you how to do that.

Basically, the XLS export would only work for the records you’re currently seeing. If there are severalpages, only the page visible will be exported.

If that is what you’re looking for I can show you a solution we’ve implemented in the past.

1 Like

Hello Moe,

Thank you, sounds great!!

Could you help me with that?

BR

I can’t guarntee this, but here’s the gist.

Add footer code (Settings > Custom Header/Footer Code):

<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.min.js" integrity="sha512-Bkf3qaV86NxX+7MyZnLPWNt0ZI7/OloMlRo8z8KPIEUXssbVwB1E0bWVeCvYHjnSPwh4uuqDryUnRdcUw6FoTg==" crossorigin="anonymous"></script>

  1. Enable the Export in the table component

  2. Get the component_id of the table

  3. Add this code to the Javascript section (change the component_x to your component id):

    TB.render(‘component_3’,function(data){
    function exportTable(type, fn, dl) {
    var elt = data.ele[0];
    var wb = XLSX.utils.table_to_book(elt, {
    sheet: “Sheet JS”
    });
    return dl ?
    XLSX.write(wb, {
    bookType: type,
    bookSST: true,
    type: ‘base64’
    }) :
    XLSX.writeFile(wb, fn || (‘Export.’ + (type || ‘xlsx’)));
    }
    data.ele.find(’.t-export-button’).off();
    data.ele.find(’.t-export-button’).click(function(){
    exportTable(‘xls’);
    });
    });

I’ve seen this used in some apps to export several tables on the same page into an Excel workbook. It’s very neat JS library.

1 Like

Sorry Moe, but I dint’t program in the last 10 years. I undestand what you are telling me, but I am not sure how to implement. :0(

Could you help me with it??

Sorry again!!

Sure, no worries. We are a no-code platform officially.

First copy and paste the script code and paste it in the footer like so:

Next, find the Component ID of the table you want to export:

Double click on this table component and enable the Export option:

Finally, open the Javascript of this page, and paste the Javascript code into it. Be sure to change the component_20 to the number of your component which you found in step 2 above.

Here’s the Javascript code again:

TB.render('component_20',function(data){
    function exportTable(type, fn, dl) {
        var elt = data.ele[0];
        var wb = XLSX.utils.table_to_book(elt, {
            sheet: "Sheet JS"
        });
        return dl ?
            XLSX.write(wb, {
                bookType: type,
                bookSST: true,
                type: 'base64'
            }) :
            XLSX.writeFile(wb, fn || ('Export.' + (type || 'xlsx')));
    }
    data.ele.find('.t-export-button').off();
    data.ele.find('.t-export-button').click(function(){
        exportTable('xls');
    });
});

Please let me know if this works for you or you have any additional questions.

1 Like

Oh Moe!!

Thank you very much it works!!!

I will not waste more time trying it.

All the best!!

Moe,

I want to include the date to the Export file, How I can do that??

Thank you