Need TableTools export functionality to work without Flash.

Need TableTools export functionality to work without Flash.

imhalfpirateimhalfpirate Posts: 9Questions: 0Answers: 0
edited December 2011 in TableTools
I just started using Datatables and just found out they have this TableTools plugin to export to Excel, PDF, etc which is perfect! The problem is though that I need this export functionality to work for my clients without flash. Is their any way to call these functions without using the SWF file? I'd like to call these export options using regular HTML input buttons if I can.


  • allanallan Posts: 52,290Questions: 1Answers: 7,965 Site admin

    I think there are basically three ways in which the export can be done:

    1. Using the data:// protocol to create a file and have the browser save it. There are two issues with this method, firstly it wasn't supported in older IE versions (6-8 I think), and TableTools needs to support those browsers. Also the Excel export currently needs to do a UTF16-LE output, rather than UTF8 (that might not be true with the new Excel XML format, that's something I've yet to investigate), and I don't know of a way to do that binary type convert ion in Javascript.

    2. Using a server-side script to create the file and have it downloaded to the browser. The reason I didn't do this as the default method is that it would mean a server-side script would have to be installed for every TableTools install, and it would obviously need to match the server-side environment available. If you do want to do this, can create your own server-side script, there is the 'download' plug-in for TableTools which will send everything you need to create the file on the server, to the server:

    3. Use Flash to create the files and save them locally. This is the option I went with, since the others had restrictions that weren't acceptable on them.

    I realise that the Flash option is far from perfect (certain aspects of it are a bit of a nightmare to be honest!), but I don't currently see a workable alternative. If anyone has any suggestions that I'm all ears!

  • imhalfpirateimhalfpirate Posts: 9Questions: 0Answers: 0
    I'll try out the 2nd option. Thanks for the prompt response Allan. Appreciate it!
  • haiyuezhanghaiyuezhang Posts: 1Questions: 0Answers: 0
    For those who might need this:

    Before using DataTable I had a jQ function that copies my html table to Excel. Here is the code:

    //re-format the content so excel fill the datasheet correctly
    //otherwise everything will be pasted in 1 cell in excel
    var rows = [];
    $('#datatable tr:visible').each(function() {
    var columns = [];
    $(this).children("td").each(function() {
    //delimiter tab between each cell
    //delimit newline between each row
    var data = rows.join("\n");
    //copy content in user clipboard buffer
    window.clipboardData.setData('Text', data);
    alert('Copied! You can now paste it in Excel.');


    this doesn't need flash obviously but doesn't' really work in Firefox, only IE! (which is fine for me since I only need to support IE for my work)

    It might give some of you a hint to make it compatible with FF (?)
This discussion has been closed.