Parse Word document to upload data to database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anandhkumar
    New Member
    • Jun 2009
    • 1

    Parse Word document to upload data to database

    hi dudes

    can anyone there guide me in parsing word document to upload the data from word doc to d/b using ruby on rails... It would be helpful if i get a sample description of that code...
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    I've moved your post to the correct place, so that the experts can have a look at it and perhaps provide some clues. Oh, and welcome to Bytes!

    -Moderator

    Comment

    • improvcornartist
      Recognized Expert Contributor
      • May 2007
      • 303

      #3
      You can use win32ole to parse the Word documents, then just grab the text and save it in the database. Here's an example for getting text out of a Word document:
      Code:
      require 'win32ole'
      word = WIN32OLE.new('word.application')
      word.documents.open(path_to_file)
      
      # select whole text
      word.selection.wholestory
      
      # read the selection
      puts word.selection.text.chomp
      
      # close document
      word.activedocument.close( false ) # no save dialog, just close it
      
      # quit word
      word.quit

      Comment

      Working...