Skip to content Skip to sidebar Skip to footer

Html To Excel Export

I have a table in HTML format.
IDNameMonth

Solution 1:

if you mean, as statet by VinayC in one of the comments, to export the generated HTML without having to make another trip to the server, it works just fine with Downloadify.

Description on GitHub:

This library is a tiny JavaScript + Flash library that allows you to generate files on the fly, in the browser, without server interaction. Web applications that allow you to generate vCards, color palettes, custom code, etc would benefit from using this library. In addition to increasing speed (no round trip to the server) this solution can reduce the database and server load of existing web applications. This is not a library to ‘force download’ a file from a server. It does not interact with a server at all.

I am actually using it together with jquery 1.4.4 in our business-environment. I have to display tables with 10k+ rows and about 15 cols which make up for 13.5mb of data.

$('#tbl_purchase_groups_download').downloadify({
            'filename' : 'Purchase_groups.xls',
            'data' : html_wrapper_pre + document.getElementById('purchase_groups').innerHTML + html_wrapper_after});

html_wrapper_pre and html_wrapper_after are the opening and closing html-structures with provided encoding.

Solution 2:

Why does it have to be MSExcel format?

You can't (easily) get from an HTML page to a local file using javascript. OTOH if the source data is not HTML and you've got a serverside programming language, you can serve up the file in a suitable format - but I'd very strongly recommend using text/csv rather than application/vnd.ms-excel

With MSIE you can copy from an html page to the clipboard - but that's an MSIE only function.

Solution 3:

You can export a HTML table to Excel using pure JavaScript. Here is a working example: http://jsfiddle.net/y0jwhnco/1/

var a = document.createElement('a');
    var myFileName = 'MyFileName.xls';
    a.download = myFileName;
    a.setAttribute('href', uri + base64(format(template, ctx)));
    a.appendChild(document.createTextNode(myFileName));
    document.getElementById('myTable').appendChild( a);

Post a Comment for "Html To Excel Export"