TableTools v1.0.2 - Save as Excel, CSV, copy and print! - Page 2

TableTools v1.0.2 - Save as Excel, CSV, copy and print!

2456

Replies

  • squigsquig Posts: 14Questions: 0Answers: 0
    Hi Allan,

    ok, just realized (again) why its called "Cascading style sheet" -.-

    On a very high level was a definition which had broken TableTools. My fault. Sorry for that.


    squig
  • brazbraz Posts: 12Questions: 0Answers: 0
    Hi allan,

    Thanks for newe useful feature.

    I think that many users will also like a kind of opposite feature: create dataTable from CSV or simple XLS file.
    I think it can be implemented in the next way:
    1. User posts the CSV or some other supported file on the server.
    2. Server side script parses the file to to native dataTable JSON format
    3. Data table makes AJAX request to the server to get the data and redraws itself.

    What do you think about that ?
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi Braz,

    Sounds like a very interesting idea. It should be fairly straight forward to do a transform from CSV to a JSON format for DataTables (or any source source to JSON transform, XML etc) and then use this tool in combination with DataTables to save it however you want. I like it :-)

    Allan
  • brazbraz Posts: 12Questions: 0Answers: 0
    I think that parsers for commonly used text data formats to JSON exist. Maybe will try to implement this feature as a plugin to dataTables
  • orchid1orchid1 Posts: 18Questions: 0Answers: 0
    this plugin saved me like 1,000 hours worth of work

    man DataTables is awsome

    love it
  • adamadam Posts: 11Questions: 0Answers: 0
    edited August 2009
    Hi allan

    First of all, thank you so much for sharing your work. TableTools IS amazing. As orchild1 says above, it saved me tonnes of work! I was blown away with DataTables and TableTools is just the cherry on the cake :)

    I have a few issues that I'm hoping you can assist me with:

    1) When I export with the .xls button, my ampersands are getting encoded. So I end up with & amp ; (spaced to avoid it displaying as $amp; in the browser) in the spreadsheets. How can I turn this off?

    2) The export option breaks accented characters (my data is UTF8). Is there a fix or work-around for this?

    3) The copy and Excel buttons break in some versions of IE. But this may also be linked to the version of Flash. Are you specifying a Flash version in your code. Where is it? I'd like to lower it to see if this helps the situation.

    Sorry if this sounds like I'm picking holes in it, that's not my intention. I'd love to roll this out through out my whole site, but these are just my last few niggles.

    Please help and thank you again!
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi adam,

    Great to hear that TableTools is really useful - it makes it all worth while when it's used!

    1. This is quite odd - I suspect it's something to do with the Javascript -> Flash bridge, but I'll need to debug what is actually going on (plus my trial version of Flash I used to create that button has expired - doh).

    2. Again (and without known any better) I'm going to point the finger of suspicion at the comms bridge. But that will need some debugging as well - quite important to make that work!

    3. Flash 10 is required (due to the 'save to local file system - which was introduced in Flash 10). I had thought that I had included the relevant tagging required to make Flash 10 required by the browser - but it's possible I've made a mistake there. Or it's possible that the browser just isn't prompting for the Flash upgrade, if Flash 9 is installed.

    Regards,
    Allan
  • adamadam Posts: 11Questions: 0Answers: 0
    Hi allan!

    Thanks for the quick reply. I'm well impressed you build this during a Flash trial period!

    1/2. If you could investigate this in the next few weeks I'll buy you a few pints via the donation page :)
    I'd really like to set this live and this is the only thing holding me back now.

    3. There is no prompt for version 10. After more investigation we realised that it only breaks in IE 6/7 browsers that have Flash <10. But we are using some flash on the previous page, so will do our own prompt for v10 there, then it wont be an issue.

    If there is anything I can do with regards the first point please let me know.

    Thanks for your time,
    Adam
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi Adam,

    1/2 - I'll certainly have a look at this, but it will be at least a week before I can do so I'm afraid - heading off on holiday soon and not taking a computer! When I get a chance to update the flash software I'll update this thread.

    3. Good to hear it won't be an issue for you - but I'll look into why it's not promoting for flash 10 anyway.

    Regards,
    Allan
  • izaiza Posts: 1Questions: 0Answers: 0
    edited August 2009
    I found a bug:
    If no filename option is supplied (so it defaults to page title), and the page title contains illegal characters, the export buttons don't work; no error message is given (unless you have the flash debugger plugin installed), the save dialogue simply doesn't open. Should be a simple matter of stripping illegal characters from the page title string before passing it to the file dialogue.
    Took me forever to figure out why it wasn't working..

    Another minor issue, the csv export doesn't account for existing commas in the table cells, so if your table data contains commas, the csv file gets messed up. (either stripping out commas or enclosing the values in quotes should work)
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi iza,

    Thanks very much for letting me know about these bugs! I'll have a look at fixing them in the next revision of TableTools - hopefully not to far in the future).

    Regards,
    Allan
  • alimontialimonti Posts: 9Questions: 0Answers: 0
    Hy Allan,
    i'm starting to use your library and i think it is very well done.
    I'm using the plugin TableTool too, version 1.0.2 with the last version of dataTable ( 1.5.1) with Firefox 3.5.

    It works great until it handles more and less 4 thousand rows,
    but as soon as it exceeds this number of rows...it stop to works and i can't more save the rows into a file or copy to a clipboard.

    There is a maximum number of rows to handle?

    I need to handle a bigger number of rows ( over 40 thousands ) there is a way to do it or am i mistaking something?

    Thank u for all.
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi alimonti,

    I'm guessing that you've run into a limitation in the amount of data that can be transferred over the Javascript / Flash bridge. I'm not sure how big this limit might be (assuming that there is indeed one), but I can't think of any other reason why it wouldn't work. If you reduce it to 1000 rows (or even smaller) does it then work?

    If this is indeed the case, then what you will probably need to do is use some kind of server-side processing to output the data to XSL etc.

    Regards,
    Allan
  • alimontialimonti Posts: 9Questions: 0Answers: 0
    Hy Allan,
    thank u for your reply.

    Yes, if i reduce the number of rows it works ( more and less until the file size is 350 KB).

    Do u know if there is a way to set this limit on Javascript /Flash Bridge transfer data?
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi alimonti,

    A quick scout around on the web shows that you might indeed be hitting a hard limit to the External Interface that Flash is using:

    http://board.flashkit.com/board/showthread.php?t=719855
    http://blog.deconcept.com/2005/08/16/external-interface/

    So it's undocumented and not much we can do about it. Sorry. Best bet might be to ask around on the Adobe forums, but I rather suspect you might need to post your data to a server (you can hack TableTools do to this instead of passing it to flash) and then have it do whatever saving of files you need.

    Regards,
    Allan
  • alimontialimonti Posts: 9Questions: 0Answers: 0
    Hy Allan,
    thank u for your quick reply.

    I think that i will use your TableTools like it is, ( i prefer to don't hack it so that i can update it without effort :) ) and i will add a way to download the data from the server.

    May i suggest u a thing?
    I was using also KeyTable tool to navigate on the table but to be perfect it should have to handle also SHIFT and CTRL keys to allow multiple selection. :)

    Again a time, thank u for this wonderful tools u did, i'm using dataTables like a window for the DataBase ( for this i need to handle all this rows ) and it is exactly what i was looking for.

    Ciao Allan.
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi alimonti,

    Your idea of being able to handle modifier keys to select more that one cell. It would be a fairly significant update (and would need consideration for how to deal with events, particularly editing etc), but I've added it to the wish-list :-)

    Regards,
    Allan
  • llirikllirik Posts: 2Questions: 0Answers: 0
    Where exactly is TableTools handling stripping the html? One thing it doesn't strip out is spaces written by code (as in,  ).

    In my table, a few rows also have a hidden DIV for displaying additional information... the HTML gets stripped, but the content of the div still continues through. I would tell TableTools so completly strip out the contents of a certain class before it destroys the html elements. So basically, where does it do this work? I'm having trouble finding it.

    Thanks.
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi llirik,

    In the function fnGetDataTablesData() you'll see two instances of ".replace( /<.*?>/g, "" )" in the code - one for the titles, and one for the rows. This is where the tags are stripped. You can manipulate the data here as needed.

    Regards,
    Allan
  • JustLikeIcarusJustLikeIcarus Posts: 8Questions: 0Answers: 0
    Hey Allan, Im looking for a way to have the print display appear in a jquery ui dialog instead of the current method. Ive looked through the table tools code and dont see how I could do it with the code as it is. What is your opinion on the best method for this? Would I need to clone the table? Thanks in advance for any help you can provide.
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Hi,

    Interesting one! I don't think the current "print" code will be all that suitable, as it keeps the current table in the DOM, and hides all the other elements on the page - in order that the CSS information targeted at that table will still remain valid.

    As such, I think you might need to write a function which will use fnGetDataTablesData() to get the information from the DataTable - something a bit like the current "fnFeature*" functions. With the information from the DataTable, you can then populate a new table in the JUI dialogue box.

    How does that sound?

    Regards,
    Allan
  • JustLikeIcarusJustLikeIcarus Posts: 8Questions: 0Answers: 0
    That could work. Another thing I was thinking after looking at some jquery plugins which print only specified sections of the page using iframes. Was to modify the tabletools function to draw the table send it to an iframe then revert back. Mostly Im just tossing ideas around, for ways to keep my user base from screaming "OMG Where did everything go!" Even though there is an alert telling you your in print mode... I know it will happen lol.

    It could also be as simple as just calling a window.print() after table is drawn and everything is hidden then reverting. so once print is done the page is fully viewable again.....

    Any suggestions?
  • Fredon78Fredon78 Posts: 12Questions: 0Answers: 0
    Hi Allan,

    Just to let you know that I got the same bug as Iza. The title of my web page contains blank space so when I want to export the table as an excel table it doesn't work without any error message.
    So I was wondering what is the javascript code to give a default name for the file.
    It seems that I have to assign a file name to the variable _oSettings.sTitle but I don't know the correct way. So if you could give me a tip.
    By the way in the function fnGetTitle I would apply a function which strip out Blank space / forbidden characteres. to the following piece of code :
    [code].
    document.GetElementByTagName('title')[0].innerHTML.
    [/code]

    Regards,

    Fred
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    @JustLikeIcarus: Yup - I was slightly concerned about the whole "OMG Where did everything go!" as well - hence the "alert". It could be made more obvious, is one option. But as you say, a better option might be to use the internal functions that TableTools provides and just write the table out into an iFrame. All of the data is there, and readily available for formatting etc, so it should be fairly easy just to create an iFrame with an HTML document inside it and a table. The table would be unformatted, but that might not be much of a concern for printing anyway.

    I decided to try and come up with a method from keeping the formatting partly because it was a novel ideal (programmers...) and showing that it can be done, and partly because I thought there would be lots of "where did my formatting go" questions if I just stripped it out! So yes, I think replacing the current print function (or providing an option would be even better) with an iFrame / plain table option - or even a popup window - would do the trick nicely.


    @Fred: Quite right - fnGetTitle() needs a modification to remove characters which are not allowed by the operating system. This is something I'll add to the next release of TableTools... But for now, if you want to make use of sTitle, all you need to do is:

    [code]
    TableToolsInit.sTitle = "whatever";
    [/code]
    just before you initialise TableTools.

    Regards,
    Allan
  • adamadam Posts: 11Questions: 0Answers: 0
    edited September 2009
    Hi Allan

    I previously reported that ampersands where still encoded when using the XLS export. Just to let you/anyone else know, that if you edit the fnGetDataTablesData() function and add an extra replace one (one for title, one for body) then it fixes this issue:
    [code]
    sData += _DTSettings.aoData[ _DTSettings.aiDisplay[j] ]._aData[ i ].replace(/\n/g," ").replace( /<.*?>/g, "" ).replace( "& amp ;", "&" ) +sSeperator;
    [/code]
    But foreign characters (French, German etc) still either break or are just cut out. Can you think of a better way of dealing with this rather than add a long list of replace's?

    Thanks for sharing your work.

    Adam
  • llirikllirik Posts: 2Questions: 0Answers: 0
    thanks for the tip on the fnGetDataTablesData()! solved my problem.

    in Safari 4 however, using the "esc" key to exit out of print mode does not work, yet it does on Firefox. I'm not able to find the cause for this bug. The only thing edited in tableTools was the addition of some characters to be stripped nothing else.

    I'm a bit stumped on this. :S
  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    @Adam: Thanks for this. Yes - I think you are right - a more generic solution is needed. I'll look into what might be possible...

    @Ilirik: I think that this is due to the bound event. $(document).bind( "keydown", null, fnPrintEnd ); is the key line here - it should be keydown - but it might be keypress in the version you have.

    Regards,
    Allan
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    Hello,

    When I try to export in csv or xls (print works fine) I got an empty file.
    I tried to copy data to clipboard too but i got nothing.

    Using firefox, i didn't see any error or missing file.

    Any idea ?
  • alimontialimonti Posts: 9Questions: 0Answers: 0
    Hy Shadok,
    i had the same problem,
    it depends on the number of the rows that u are downloading.
    In my case the save options works fine until 4 thousands rows, if i exceed this number it doesn't work anymore.
    Check my post with Allan for further details.
  • ShadokShadok Posts: 19Questions: 0Answers: 0
    Well i only have one hundred and a few lines :)
This discussion has been closed.