Solved

Fetching Data from database into MS Word

Posted on 2003-11-04
12
517 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
ID: 9685008
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
ID: 9685032
Can this be done using javascript
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 9685055
>>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
ID: 9685243
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
ID: 9685276
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
ID: 9685279
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:ross_123
ID: 9685363
You r right. It works for excel but not for word
0
 

Author Comment

by:ross_123
ID: 9685373
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
ID: 9685396
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
ID: 9685508
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
ID: 9685555
thanks a lot
0
 

Author Comment

by:ross_123
ID: 9685575
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to access elements of included jsp  from parent jsp's save button 9 21
maven scope 1 126
J2SE 5.0 metadata 1 51
Can't access image with tomcat/html 6 95
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
A short film showing how OnPage and Connectwise integration works.

929 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

12 Experts available now in Live!

Get 1:1 Help Now