Export any Data Collections to MS Excel using Wix Code (Video)

Hey there!
There is a lot of people that have been asking how can we export data from our Data Collections to a real MS Excel file. You can export data inside the data manager as CSV and then open that in MS Excel.

But if you want this function for your clients / site visitors it hasn’t been that easy right?

I have found out that there is actually a really simple way to do this. MS Excel will parse any HTML formatted table with table rows and table cells as columns and cells. So what I did was to test if I could find code snippets to create tables from JSON formatted data and I did.

Then I managed to make some code to actually export that HTML table to a file that the browser will think is a pure MS Excel file.

The only thing you will need is a Data Collection to use, a button that someone will click on and a hidden html component with some code inside. That’s it! It seem to work really well from my testing.

So watch the video I just made for you all and download the source code for your HTML Component at the button of this post. I hope you will enjoy this, any feedback is greatly appreciated from you all.

Code for HTML Component can be found here:

#htmlcomponent #msexcel #excel #datacollection #button #export

2 Likes

This is awesome! Thank you for sharing.

Do you know how to take data from a site and push it into a pdf document?

Hey, do you mean like taking a page and create a PDF from that page or do you mean to use structured data from data collection to create a PDF page?

1 Like

@andreas-kviby To take certain data from a collection and have it displayed in a pdf format. So for example if I wanted to create a pdf schedule or receipt or a catalog perhaps…

Hi, I’m really interested in this PDF functionality as well!
I’ve tried with PDFShift and the pdf-generator-api
https://www.salman2301.com/forum/wix-code-advance/create-pdf-using-wix-code-and-pdf-generator-api but there seems to be a problem with the api buffer so not successful yet on this one.

@Andreas Kviby Is there a way to just export a few columns to excel? Because now I get also the columns of the ID and Creation Date etc. Also does this code work for .xlsx too?
Thanks a lot!

Hi @laurensvandamme ,

To just show a few columns, you can use a hash map in Javascript within Corvid:

if (results.totalCount > 0)
{
    let items = results.items;
    items = items.map(function(obj){
        return {email: obj.email, username: obj.username}; 
        //only shows the columns that you want
    });
    $w("#html1").postMessage(items);
}
1 Like