Solved

Fetching Data from database into MS Word

Posted on 2003-11-04
12
515 Views
Last Modified: 2010-04-01
I need to fetch data from database(mysql) and display it in MS word in a formatted way.
Plz suggest how can this be done.
I am using JSP
0
Comment
Question by:ross_123
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
JSP is server side language, i doubt it can integrates with your local word application. However, it's possible to do it, that's using the Mail Merge function available in M$ Word.

First, try export your data into a Header file, or to Access.

Then you can follow the Mail Merge wizards to show your data inside a word document.

This link shows you how to create Mail Merge document:
http://www.mvps.org/word/FAQs/MailMerge/CreateADataSource.htm

Hope this helps
0
 

Author Comment

by:ross_123
Comment Utility
Can this be done using javascript
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
>>Can this be done using javascript
No, if you want to display the info on web, you will need to create a page where involved the scripting to format your data. Javascript is no use in this case, and What Mail Merge suggested above will be an 'offline' suggestion.
0
 

Author Comment

by:ross_123
Comment Utility
I have provided the user with a button. When he presses that buttonThe data is fetched from the database and shown to him on his machine which he can manipulate in any way he wants.
How can this be done to MS Notepad so that I can transfer it to word using mail merge
thanks
0
 
LVL 15

Expert Comment

by:dualsoul
Comment Utility
i can suggest you, to create your Word document on server side, and send it back to client, you can build Word document on server in two ways:
  1) use jakarta POI project (avaliable at jakarta.apache.org)
  2) if your server run on Windows and have MSOffice installed, you can write native dll in C++ which will construct Word document, and then use this dll from java, using JNI.

 
0
 
LVL 15

Accepted Solution

by:
jimmack earned 335 total points
Comment Utility
I know that you can return a table from a JSP that will be opened by Excel using

<%@ page contentType="application/vnd.ms-excel" %>

Is there an equivalent for word?  eg.

<%@ page contentType="application/vnd.ms-word" %>

It's a bit tricky for me to test.  I use Linux ;-)
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ross_123
Comment Utility
You r right. It works for excel but not for word
0
 

Author Comment

by:ross_123
Comment Utility
oops sorry
Tried again and its working for word.
But there still remains one problem. It displays the whole table as it is in the word document. But I want to display it in a particular format.
Will that be possible
Thanks for help
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
So the vnd.ms-word works?

Wow.  That was a good guess ;-)

I'm not quite sure what the problem is with the format.  What formatting do you want?
0
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
But, despite you can word document in your browser, but how you display the data to the word document? I think it will only works if the document is linked to a data source. Or others have their ideas?

cheers
0
 

Author Comment

by:ross_123
Comment Utility
thanks a lot
0
 

Author Comment

by:ross_123
Comment Utility
thanks ryancys.
i am  getting ur point.
What is happening here is that the html table (which is populated with data) is displayed as it is in the word or excel sheet.
Linking word to the data source would be a bit complex , I guess ;)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now