Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Problem

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
plz anybody post the answer !!!
thanks .
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't the word-clients open an open format like html?
Then you could write the file using
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic