Solved

Fetching Data from database into MS Word

Posted on 2003-11-04
12
519 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 50

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 50

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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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
 

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 50

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading data  from excel sheet and displaying 1 82
parse example 13 94
print map entry 34 67
throw exception 21 42
One of the biggest threats facing all high-value targets are APT's.  These threats include sophisticated tactics that "often starts with mapping human organization and collecting intelligence on employees, who are nowadays a weaker link than network…
One of the biggest threats in the cyber realm pertains to advanced persistent threats (APTs). This paper is a compare and contrast of Russian and Chinese APT's.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

816 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

9 Experts available now in Live!

Get 1:1 Help Now