Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

write to text file in tabular form  RSS feed

 
Ken Ng
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need help!
Any one knows how to write data to a text file in a tabular form.
E.g An table consisting of 7 rows and 8 cols that looks like the ordinary table created in microsoft Word
Don't want this (using '|' , '=' ,'-' characters to format table)

Thanks
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a plain text file? Can't be done. MS Word uses a proprietory format to store information on the format and contents of a table. Unless you want to reverse-engineer their format. . .
Maybe generating an HTML file would be an option? Creating an HTML table is pretty easy and everyone has a browser.
 
Ken Ng
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know HTML but how to generate the HTML table from java?
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Supposed a table with 2 rows and 3 cols (to keep the example tiny).
Your output shall look like this: (Oh - I hope this UBB-thing will get it right)

With h1 meaning header column1, ...
vXY meaning value row X column Y
Perhaps we need a table-object?

You may iter over the rows, and inside the rows over the columns.
The ctor could be called with an Array for the header, and a two-dim String-Array for the values.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!