Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript to export data from SQL to word

    Hi,
    is it possible to create a script which exports data from a SQL server into MS Word?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,907
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by animelover72 View Post
    Hi,
    is it possible to create a script which exports data from a SQL server into MS Word?
    Nope. JavaScript is purely a client-side language, and unless used with an Ajax call has no capability to read from or write to a file (except a cookie), communicate with the server or access a database.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,292
    Thanks
    10
    Thanked 583 Times in 564 Posts
    you could use ajax to fetch the data, and a dataURL to send it to word, but in all likelyhood, it's going to be simpler to do it all on the server.

    Keep in mind that if you serve an HTML page with a word mimetype, the page open in word and acts like a document...
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,121
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Well, technically, you *CAN* write a script to do exactly what he asked for.

    You just create a ".js" file and execute it via the Windows Script Host.

    Has nothing whatsoever to do with a browers or HTML. Has to be done from the windows command line or equivalent.

    But even doing it that way it's a really tough thing to do. You have to treat MS Word as an ActiveX object and you have to use all the internal objects of MS Word with all of their thousands and thousands of obscure and poorly documented methods.

    So the answer to "is it possible" is actually "yes."

    But probably not the way you would want it to be.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok.

    It seems more trouble than its worth if thats the case.

    Thanks guys.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •