Solved

Fetching Data from database into MS Word

Posted on 2003-11-04
12
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 51

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 51

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 51

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 group array of objects ? 5 73
rebasing and merging used in SCM 1 81
immutable object concept 5 134
Best practices to work on a spring MVC project 1 129
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

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