• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Problem

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
plz anybody post the answer !!!
thanks .
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic