This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes File Problem  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "File Problem  " Watch "File Problem  " New topic
Author

File Problem

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Hi everybody ,
My project needs to send some data ( from the database ) in MS Word file it is easy but the problem is I want some particular format in MS Word .
How can I do this .
Like first I will retrieve the student data & now I have to send that info in MS Word file but in spacial format like student name should come in big font & in center then his marks should come in a table like that .
Please help me ..
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
plz anybody post the answer !!!
thanks .
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
Hi

You can use java.awt.Font class to change the style of characters. and write back to word file using some outputstream.
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
Like first I will retrieve the student data & now I have to send that info in MS Word file but in spacial format like student name should come in big font & in center then his marks should come in a table like that


Also you can use java.awt.FontMetrics to decide and determine the length & width of characters. For placing them in center, I think you can determine the total no. of bytes that you will prefer to write in a single line in word file and then accordingly insert words in center byte positions of the line in file. Creating a table, also you can use specific byte positions along with any character to print as a line.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Damanjit Kaur:
Hi

You can use java.awt.Font class to change the style of characters. and write back to word file using some outputstream.


Ummm... no. You can do nothing of the sort. Not on Earth, anyway.

To work with Word files, you need a library that understand the Word file format. The Apache POI project is working on such a library, but the Word part is still at a pretty early stage.

If you can use RTF instead of WOrd native format, you could use iText, which is a very nice libary.


[Jess in Action][AskingGoodQuestions]
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Can't the word-clients open an open format like html?
Then you could write the file using


http://home.arcor.de/hirnstrom/bewerbung
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
Hi

Yes I was wrong to say that using Font of awt can solve this problem. thats just for displaying in awt component.

I found out from my colleague that one can also use JAVA-COM bridge called JACOB on this site http://danadler.com/jacob/ and also somewhere I read JIntegra to read, write doc files from java.

I read the iText link but it states on that link that its for writing Acrobat Reader file and not for word files writing.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Damanjit Kaur:
I read the iText link but it states on that link that its for writing Acrobat Reader file and not for word files writing.


Yes right. you can use it for RTF, as stated earlier.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Problem