Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a table in a Microsoft Office Word or Text file using Java. Can anybody tell me how to do it with an example?
Posted

1 solution

A table in a text file is quite simple as you just decide how long each field should be and ensure you fill out each line of text with the appropriate number of spaces, to end up with something like:
==========+==============+===================
| field 1 | field 2      |    field three   |
==========+==============+===================
| field N | field N+1    |    field N+2     |
==========+==============+===================

However, creating a Word document is less easy as you need to use some library which will do all the hard work of formatting your data into the structures required by Microsoft Office; here[^] are some possible options.
 
Share this answer
 
Comments
CurrentlyBE 2-Mar-12 11:17am    
Thank you Mr. Richard.
Just wanted to ask that can we store and retrieve data stored in tabular form in text field....
Richard MacCutchan 2-Mar-12 11:26am    
Yes; do you have another problem?
CurrentlyBE 4-Mar-12 8:41am    
Not yet.. If any problem shall arise I will ask it...
Our college is not allowing MS-Access to use as database for our project.. They say to use MYSQL or Oracle which we have not learnt. So group decided to use files to store information... It looks difficult too.. but we will do it...
Richard MacCutchan 4-Mar-12 8:55am    
That sounds like a very bad decision; if your college suggests you use MYSQL or Oracle then you should do what they suggest. Trying to create a database application using simple text files will lead you into all sorts of problems in the future. I would suggest that you talk to your tutor as soon as possible and be sure that you are allowed to use this method of managing your data.
CurrentlyBE 4-Mar-12 23:15pm    
Hmmm... but unfortunately there is no help from lecturers and they told us to self-study and as i said we don't know anything about MYSQL or Oracle.. how can we create database without any knowledge of it.... Main point is when will we study and when will we complete our project....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900