• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Formatting in Wordpad

 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a requirement to export the data which is shown in a Jsp file to some text file.

Here is what i have tried


And the output desired is as:

Is there any better way to do this?

Thanks
img.jpeg
[Thumbnail for img.jpeg]
Desired Output
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried tab delimited values. Use the \t escape character. Tab delimited files can also be opened in cell editors (excel like apps) since they are similar to CSV files.
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya i tried it earlier....but the client had some particular requirement where the the number of space+digit between the end of first column and end of second column be 18.

I.e spaces+digits = 18 for first, 40 for the next ....

so \t fails there......
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sumit Patil wrote:Ya i tried it earlier....but the client had some particular requirement where the the number of space+digit between the end of first column and end of second column be 18.

I.e spaces+digits = 18 for first, 40 for the next ....

so \t fails there......


Ask the client why they have this requirement. Who is going to end up using this file ? Can the client reconfigure the font / tab displays in their editor so that it looks like there are 18 spaces between ? Can they use an offline regex tool to replace \t with 18 spaces ?
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ask the client why they have this requirement. Who is going to end up using this file ? Can the client reconfigure the font / tab displays in their editor so that it looks like there are 18 spaces between ? Can they use an offline regex tool to replace \t with 18 spaces ?


Yes i know it is disgusting......but this is what they want and my team lead wants to deliver it.......
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you add 18 spaces the way you described earlier, the output will not display in the way wordpad is displaying it. This is because, unless the length of each field is fixed, the output will not look aligned.

You can work around that by calculating the max length of each column in the output. The padding between columns should then be maxColLength(col_num) + 18. A waste of processing power, efficiency and the code will probably be difficult to write / maintain.

If the reason is solely that the formatting in word should look great, its not a good reason to go through so much pain. But then again we do not live in an ideal world. You might have to end up implementing this logic, just because some one wants it
 
Sumit Patil
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:
But then again we do not live in an ideal world. You might have to end up implementing this logic, just because some one wants it

Yes that is what i have done in the addspace method. this is just delivering what the client wants......so developing and maintaining the code......
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic